mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-24 23:00:19 +03:00
Compare commits
113
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
699450c458 | ||
|
|
6d28ba6044 | ||
|
|
e8f0677f94 | ||
|
|
5bbc672017 | ||
|
|
d10b89b995 | ||
|
|
7632d99cba | ||
|
|
1d77ed3bbe | ||
|
|
83d7d33d86 | ||
|
|
0295223a3d | ||
|
|
8974b3048d | ||
|
|
6e021e9848 | ||
|
|
8d13f0a176 | ||
|
|
231930dd56 | ||
|
|
b5eace85db | ||
|
|
e7758934a8 | ||
|
|
324a6be4d0 | ||
|
|
8f94ed3619 | ||
|
|
41297c80f8 | ||
|
|
f122bafaa9 | ||
|
|
ec33d7df26 | ||
|
|
47943c76ac | ||
|
|
bb3ef34052 | ||
|
|
d77917f24c | ||
|
|
d6e478c277 | ||
|
|
788d4fdded | ||
|
|
8ec559012d | ||
|
|
b64d2a1742 | ||
|
|
6241fa6352 | ||
|
|
3af8e4a4cd | ||
|
|
81c12017ce | ||
|
|
d53e745854 | ||
|
|
94c0bbfcbc | ||
|
|
b536f040be | ||
|
|
4a80283786 | ||
|
|
ea30976669 | ||
|
|
bb00dcb8de | ||
|
|
de40fc7a98 | ||
|
|
a891be1a13 | ||
|
|
1b8d4879ac | ||
|
|
0203c2388a | ||
|
|
d785329e74 | ||
|
|
f1b20c7c18 | ||
|
|
3872432a07 | ||
|
|
9b655473bc | ||
|
|
b688f528bd | ||
|
|
3e7f8459ff | ||
|
|
4e5c0fd401 | ||
|
|
e179bd5b9b | ||
|
|
44f1298471 | ||
|
|
f196182261 | ||
|
|
cba443dc39 | ||
|
|
fad759efda | ||
|
|
fd37ca3dda | ||
|
|
51cb09339c | ||
|
|
6aa2e1cebb | ||
|
|
90b779356f | ||
|
|
da38faa9be | ||
|
|
7fc4b79172 | ||
|
|
641fa857b4 | ||
|
|
0f4c7b1d68 | ||
|
|
c96fd39482 | ||
|
|
bc1d9a3199 | ||
|
|
c80a08be64 | ||
|
|
0039bd7213 | ||
|
|
62ab0bf92f | ||
|
|
a049d1c519 | ||
|
|
bc44870665 | ||
|
|
5bf94bc567 | ||
|
|
a5607e04ad | ||
|
|
39c616f609 | ||
|
|
002a211ca5 | ||
|
|
0a1f5dc450 | ||
|
|
ec740dd063 | ||
|
|
2912cf3eb9 | ||
|
|
fbc7d47fbd | ||
|
|
d39255ac20 | ||
|
|
903ffb8b90 | ||
|
|
5e4972e285 | ||
|
|
8b7bc0a650 | ||
|
|
69f508442c | ||
|
|
c82794af62 | ||
|
|
07102a6128 | ||
|
|
04cfee6f3e | ||
|
|
db3a344568 | ||
|
|
671e8a11c7 | ||
|
|
9bc3cb74b5 | ||
|
|
db9ac4e729 | ||
|
|
bc12798327 | ||
|
|
e725356eee | ||
|
|
6e89d3dd03 | ||
|
|
27ab891343 | ||
|
|
e5a2017f7d | ||
|
|
be4d22587f | ||
|
|
66e2ac5df2 | ||
|
|
fb6cc731f5 | ||
|
|
38643233a3 | ||
|
|
f1358d55b4 | ||
|
|
c105c1ec17 | ||
|
|
2abda9b71e | ||
|
|
65955d9b33 | ||
|
|
b1d3849f87 | ||
|
|
c4f7ded565 | ||
|
|
db32bb0835 | ||
|
|
db050b2617 | ||
|
|
96a2079283 | ||
|
|
a2d696168a | ||
|
|
e1de52bdf3 | ||
|
|
23dc0d4046 | ||
|
|
bbc819f28c | ||
|
|
aa515d96f3 | ||
|
|
175c860ec8 | ||
|
|
fe2766e554 | ||
|
|
0620f57691 |
No files matched your search
+2
-2
@@ -1,2 +1,2 @@
|
||||
github:
|
||||
- sharevb
|
||||
github: sharevb
|
||||
buy_me_a_coffee: sharevb
|
||||
@@ -22,5 +22,5 @@
|
||||
- [ ] Submit the PR against the `chore/all-my-stuffs` branch.
|
||||
- [ ] Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
|
||||
- [ ] Provide a description, in PLAIN ENGLISH ONLY, in this PR that addresses **what** the PR is solving, or reference the issue that it solves (e.g. `fixes #123`).
|
||||
- [ ] Run `pnpm install --ignore-scripts && pnpm lint:fix && pnpm typecheck` to ensure pnpm lock, oxlint and typecheck are ok
|
||||
- [ ] Run `pnpm install --ignore-scripts && pnpm lint:fix && pnpm typecheck` to ensure pnpm lock, oxlint (including type-aware rules) and vue-tsc are ok
|
||||
- [ ] Ideally, include relevant tests that fail without this PR but pass with it.
|
||||
@@ -0,0 +1,244 @@
|
||||
---
|
||||
name: Deploy
|
||||
|
||||
# Builds here and deploys the result to Vercel. The Git integration is off for this project
|
||||
# (`git.deploymentEnabled: false` in vercel.json), so this workflow is what deploys it.
|
||||
#
|
||||
# chore/all-my-stuffs goes to production. Every pull request gets a preview, linked from the
|
||||
# PR's "View deployment" button through the GitHub environment set on the job.
|
||||
#
|
||||
# Setup: VERCEL_TOKEN, VERCEL_ORG_ID and VERCEL_PROJECT_ID as secrets, on the repository or on
|
||||
# the Production and Preview environments. Optionally the VERCEL_PRODUCTION_URL repository
|
||||
# variable (e.g. https://it-tools.example.com/): production builds generate sitemap.xml and
|
||||
# robots.txt for it, and without it they are left out.
|
||||
#
|
||||
# Replaces sharevb-vercel-preview.yml and sharevb-vercel-prod.yml, which deployed the same two
|
||||
# targets without a concurrency group or a GitHub environment. One deployment per burst of
|
||||
# pushes keeps Vercel's daily deployment and upload caps, and Deployment Storage, in check.
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- chore/all-my-stuffs
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
# Per ref, cancelling in progress: pushing three times in a minute should cost one
|
||||
# deployment, not three. Production is grouped per ref too, so a rapid merge sequence
|
||||
# collapses the same way.
|
||||
group: deploy-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
# Same-repository events only. GitHub withholds secrets from `pull_request` runs on forks,
|
||||
# so a fork would fail the credentials check on every push — and more to the point, this
|
||||
# job runs the checked-out branch's build scripts with VERCEL_TOKEN in the environment.
|
||||
# That is fine for branches in this repository, whose authors already have the secrets, and
|
||||
# is not something to offer an arbitrary fork.
|
||||
# Skip renovate[bot] too as it exceeds Vercel Free Plan limits.
|
||||
if: >-
|
||||
(
|
||||
github.event_name != 'pull_request' ||
|
||||
github.event.pull_request.head.repo.full_name == github.repository
|
||||
) &&
|
||||
github.actor != 'renovate[bot]'
|
||||
runs-on: ubuntu-26.04-arm
|
||||
timeout-minutes: 15
|
||||
# Records a GitHub Deployment per run, which is what puts the Environments sidebar, the
|
||||
# "deployed to Preview" PR timeline entry and its "View deployment" button back — the parts
|
||||
# of the Vercel Git integration lost when building moved here. The names match the
|
||||
# environments that integration created, so their history carries on. The condition has to
|
||||
# be restated rather than read from the `target` step: the environment is fixed before any
|
||||
# step runs. `url` is evaluated at the end, so it can use the deploy step's output.
|
||||
environment:
|
||||
name: >-
|
||||
${{ github.ref == 'refs/heads/chore/all-my-stuffs' && github.event_name != 'pull_request'
|
||||
&& 'Production' || 'Preview' }}
|
||||
url: ${{ steps.deploy.outputs.url }}
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Fail early if the Vercel credentials are missing
|
||||
env:
|
||||
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
|
||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
||||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
missing=""
|
||||
for name in VERCEL_TOKEN VERCEL_ORG_ID VERCEL_PROJECT_ID; do
|
||||
[ -z "${!name}" ] && missing="$missing $name"
|
||||
done
|
||||
if [ -n "$missing" ]; then
|
||||
# Either place works, so name both rather than send anyone to the wrong settings
|
||||
# page.
|
||||
echo "::error::Missing secrets:$missing — set them on the repository (Settings > Secrets and variables > Actions) or on the Production and Preview environments (Settings > Environments). See .github/workflows/deploy.yaml"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
# On pull requests, the exact commit that triggered the run, not GitHub's detached
|
||||
# merge commit: this builds the PR's own head, as Vercel's Git integration did.
|
||||
# Pinned to the event's SHA rather than the branch name, so a push that lands while
|
||||
# this run is queued, or a re-run of an old run, can't deploy a different commit
|
||||
# under this run's deployment. Empty on push and workflow_dispatch, which keeps the
|
||||
# default ref.
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
# The Vercel CLI reads the deployment's branch and commit message from git. A detached
|
||||
# checkout shows up in Vercel as branch "HEAD", so name the commit after the PR branch.
|
||||
- name: Name the checked-out commit after the PR branch
|
||||
if: github.event_name == 'pull_request'
|
||||
env:
|
||||
# From the environment, not interpolated: branch names can contain shell
|
||||
# metacharacters.
|
||||
HEAD_REF: ${{ github.head_ref }}
|
||||
run: git checkout -B "$HEAD_REF"
|
||||
|
||||
- uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0
|
||||
with:
|
||||
cache: true
|
||||
|
||||
- name: Install Vercel CLI
|
||||
# Into a scratch directory outside the repository, not globally: `pnpm add --global`
|
||||
# needs a global bin directory that `pnpm/setup` does not configure, and it failed
|
||||
# immediately on the first run with the secrets in place. Installing here also keeps
|
||||
# package.json and the lockfile untouched, so the tree the build sees is the tree that
|
||||
# was committed.
|
||||
#
|
||||
# Pinned: an unpinned CLI changes how this workflow builds and deploys with no commit
|
||||
# here to explain it.
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p "$RUNNER_TEMP/vercel-cli"
|
||||
cd "$RUNNER_TEMP/vercel-cli"
|
||||
pnpm init >/dev/null
|
||||
# Build approvals as config rather than --allow-build flags, matching how the
|
||||
# repository declares its own. This directory is outside the repository so it
|
||||
# inherits nothing; both packages that run install scripts are named here. esbuild
|
||||
# is the one that actually needs it — a transitive dependency of the CLI whose
|
||||
# postinstall links its native binary.
|
||||
#
|
||||
# minimumReleaseAge is deliberately not set: pnpm's built-in default is already
|
||||
# 1440 minutes, so restating it would only create a second place to keep in sync.
|
||||
printf 'allowBuilds:\n vercel: true\n esbuild: true\n' > pnpm-workspace.yaml
|
||||
pnpm add vercel@60.1.3
|
||||
echo "$RUNNER_TEMP/vercel-cli/node_modules/.bin" >> "$GITHUB_PATH"
|
||||
|
||||
# Environment is decided once and reused, so the pull, the build and the deploy cannot
|
||||
# disagree about which one they are targeting.
|
||||
- name: Resolve target environment
|
||||
id: target
|
||||
env:
|
||||
# Read from the environment, not interpolated into the script. workflow_dispatch can
|
||||
# run on any branch, and a branch name containing shell metacharacters would
|
||||
# otherwise be pasted straight into this `if` as source.
|
||||
REF: ${{ github.ref }}
|
||||
EVENT: ${{ github.event_name }}
|
||||
PRODUCTION_URL: ${{ vars.VERCEL_PRODUCTION_URL }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ "$REF" = "refs/heads/chore/all-my-stuffs" ] && [ "$EVENT" != "pull_request" ]; then
|
||||
{
|
||||
echo "environment=production"
|
||||
echo "prod_flag=--prod"
|
||||
echo "hostname=$PRODUCTION_URL"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
{
|
||||
echo "environment=preview"
|
||||
echo "prod_flag="
|
||||
# No sitemap or robots.txt for previews: they would advertise the preview URL.
|
||||
echo "hostname="
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Pull Vercel project settings
|
||||
env:
|
||||
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
|
||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
||||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# The link is written out rather than left to the CLI to infer from environment
|
||||
# variables. Relying on VERCEL_ORG_ID/VERCEL_PROJECT_ID alone failed here with
|
||||
# "Could not retrieve Project Settings", and which variables a given CLI version
|
||||
# honours is not something to guess at from a workflow. This file is exactly what
|
||||
# `vercel link` produces, so the CLI has nothing left to work out.
|
||||
mkdir -p .vercel
|
||||
# printf rather than a heredoc: a heredoc's terminator has to sit at column zero,
|
||||
# which it cannot inside an indented YAML block, and %s keeps the ids out of the
|
||||
# shell's word splitting.
|
||||
printf '{"projectId":"%s","orgId":"%s"}\n' "$VERCEL_PROJECT_ID" "$VERCEL_ORG_ID" \
|
||||
> .vercel/project.json
|
||||
# Shape only — the ids are secrets and are not printed.
|
||||
python3 -c "import json;d=json.load(open('.vercel/project.json'));print('link written, keys:', sorted(d))"
|
||||
vercel pull --yes \
|
||||
--environment="${{ steps.target.outputs.environment }}" \
|
||||
--token="$VERCEL_TOKEN"
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
|
||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
||||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
||||
# What sharevb-vercel-*.yml set, kept so the build is the same:
|
||||
# VITE_VERCEL_ENV is the env label the app reports (src/config.ts), and
|
||||
# VITE_VERCEL_DEPLOY turns off full PWA precaching (vite.config.ts).
|
||||
VITE_VERCEL_ENV: ${{ steps.target.outputs.environment }}
|
||||
VITE_VERCEL_DEPLOY: true
|
||||
# HOSTNAME is what vite.config.ts generates sitemap.xml and robots.txt from, so it is
|
||||
# set for production only, from the VERCEL_PRODUCTION_URL repository variable.
|
||||
HOSTNAME: ${{ steps.target.outputs.hostname }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
vercel build ${{ steps.target.outputs.prod_flag }} --token="$VERCEL_TOKEN"
|
||||
# A build that produces nothing would otherwise deploy an empty site over a working
|
||||
# one. Checked before anything is uploaded.
|
||||
test -s .vercel/output/static/index.html || {
|
||||
echo "::error::Build produced no .vercel/output/static/index.html — refusing to deploy"
|
||||
exit 1
|
||||
}
|
||||
|
||||
- name: Deploy
|
||||
id: deploy
|
||||
env:
|
||||
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
|
||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
||||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# --archive=tgz uploads the output as one archive instead of file by file. The Hobby
|
||||
# plan caps CLI uploads at 5000 files a day across the whole account
|
||||
# ("api-upload-free"), and per-file uploads hit that after a busy
|
||||
# day of deploys.
|
||||
url=$(vercel deploy --prebuilt --archive=tgz ${{ steps.target.outputs.prod_flag }} --token="$VERCEL_TOKEN")
|
||||
# `vercel deploy` prints the URL on stdout and progress on stderr, so this is the URL
|
||||
# and nothing else. Empty means the deploy did not produce one, which is a failure
|
||||
# even if the CLI exited 0.
|
||||
[ -n "$url" ] || { echo "::error::Deploy returned no URL"; exit 1; }
|
||||
echo "url=$url" >> "$GITHUB_OUTPUT"
|
||||
echo "Deployed to $url"
|
||||
|
||||
- name: Summary
|
||||
if: always()
|
||||
env:
|
||||
ENVIRONMENT: ${{ steps.target.outputs.environment }}
|
||||
URL: ${{ steps.deploy.outputs.url }}
|
||||
STATUS: ${{ job.status }}
|
||||
run: |
|
||||
{
|
||||
echo "### Deploy"
|
||||
echo ""
|
||||
if [ "$STATUS" = "success" ]; then
|
||||
echo "Deployed to **$ENVIRONMENT**: $URL"
|
||||
else
|
||||
echo "**Deploy failed.** See the failing step above."
|
||||
fi
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
@@ -6,34 +6,37 @@ on:
|
||||
branches:
|
||||
- chore/all-my-stuffs
|
||||
|
||||
concurrency:
|
||||
# A new push supersedes the previous run on the same ref, so a burst of pushes
|
||||
# costs one run instead of one per push.
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-26.04-arm
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v7.0.0
|
||||
- run: |
|
||||
echo "Before: corepack version => $(corepack --version || echo 'not installed')"
|
||||
npm install -g corepack@latest
|
||||
echo "After : corepack version => $(corepack --version)"
|
||||
corepack enable
|
||||
pnpm --version
|
||||
- uses: actions/setup-node@v6.4.0
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: Setup pnpm and install dependencies
|
||||
uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: 'pnpm'
|
||||
cache: true
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm i --ignore-scripts
|
||||
# The checks are independent of each other, so they share the runner
|
||||
# instead of queueing behind one another. The build is the long pole.
|
||||
- parallel:
|
||||
- name: Check formatting
|
||||
run: pnpm fmt:check
|
||||
|
||||
- name: Run linters
|
||||
run: pnpm lint
|
||||
- name: Run linters
|
||||
run: pnpm lint
|
||||
|
||||
- name: Run unit test
|
||||
run: pnpm test
|
||||
- name: Run unit test
|
||||
run: pnpm test:unit
|
||||
|
||||
- name: Type check
|
||||
run: pnpm typecheck
|
||||
- name: Type check
|
||||
run: pnpm typecheck
|
||||
|
||||
- name: Build the app
|
||||
run: pnpm build
|
||||
- name: Build the app
|
||||
run: pnpm build
|
||||
@@ -21,7 +21,9 @@ on:
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
# x64 on purpose: the x64 runner image ships the CodeQL bundle in its tool
|
||||
# cache, the arm64 image does not, so arm would download it on every run.
|
||||
runs-on: ubuntu-26.04
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
@@ -37,11 +39,9 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v7.0.0
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v4.36.3
|
||||
uses: github/codeql-action/init@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
@@ -55,9 +55,7 @@ jobs:
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v4.36.3
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
uses: github/codeql-action/autobuild@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
@@ -69,4 +67,4 @@ jobs:
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v4.36.3
|
||||
uses: github/codeql-action/analyze@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
|
||||
@@ -10,12 +10,12 @@ on:
|
||||
|
||||
jobs:
|
||||
check_date:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-26.04-arm
|
||||
name: Check latest commit
|
||||
outputs:
|
||||
should_run: ${{ steps.should_run.outputs.should_run }}
|
||||
steps:
|
||||
- uses: actions/checkout@v7.0.0
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: print latest_commit
|
||||
run: echo ${{ github.sha }}
|
||||
|
||||
@@ -26,44 +26,38 @@ jobs:
|
||||
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false"
|
||||
|
||||
ci:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-26.04-arm
|
||||
needs: check_date
|
||||
if: ${{ needs.check_date.outputs.should_run != 'false' }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v7.0.0
|
||||
- run: |
|
||||
echo "Before: corepack version => $(corepack --version || echo 'not installed')"
|
||||
npm install -g corepack@latest
|
||||
echo "After : corepack version => $(corepack --version)"
|
||||
corepack enable
|
||||
pnpm --version
|
||||
- uses: actions/setup-node@v6.4.0
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: Setup pnpm and install dependencies
|
||||
uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm i --ignore-scripts
|
||||
cache: true
|
||||
|
||||
- name: Run linters
|
||||
run: pnpm lint
|
||||
|
||||
- name: Run unit test
|
||||
run: pnpm test
|
||||
run: pnpm test:unit
|
||||
|
||||
- name: Type check
|
||||
run: pnpm typecheck
|
||||
|
||||
- name: Build the app
|
||||
run: pnpm build
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-26.04-arm
|
||||
needs:
|
||||
- ci
|
||||
|
||||
steps:
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v6.2.0
|
||||
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
|
||||
with:
|
||||
images: sharevb/it-tools
|
||||
labels: |
|
||||
@@ -71,29 +65,29 @@ jobs:
|
||||
|
||||
# Checkout the repository
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v7.0.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v4.4.0
|
||||
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v4.4.0
|
||||
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v4.2.0
|
||||
uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4.2.0
|
||||
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v7.3.0
|
||||
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
@@ -109,29 +103,19 @@ jobs:
|
||||
run: docker logout ghcr.io
|
||||
|
||||
github-release:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-26.04-arm
|
||||
needs: ci
|
||||
steps:
|
||||
- name: Set release version to nightly
|
||||
run: echo "RELEASE_VERSION=nightly" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7.0.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- run: |
|
||||
echo "Before: corepack version => $(corepack --version || echo 'not installed')"
|
||||
npm install -g corepack@latest
|
||||
echo "After : corepack version => $(corepack --version)"
|
||||
corepack enable
|
||||
pnpm --version
|
||||
|
||||
- uses: actions/setup-node@v6.4.0
|
||||
- name: Setup pnpm and install dependencies
|
||||
uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm i --ignore-scripts
|
||||
cache: true
|
||||
|
||||
- name: Build the app
|
||||
run: pnpm build
|
||||
@@ -148,7 +132,7 @@ jobs:
|
||||
echo "$EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v3.0.1
|
||||
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
files: it-tools-${{ env.RELEASE_VERSION }}.zip
|
||||
|
||||
@@ -1,50 +1,42 @@
|
||||
name: Build and Push Docker Image (baseurl-it-tools)
|
||||
|
||||
# Kept for the deployments already pulling the `baseurl-it-tools` tag. It is no longer a
|
||||
# different build: BASE_URL is a runtime setting now, so this image is the same one as
|
||||
# `latest` with the default moved to /it-tools/, and `latest` with `-e BASE_URL=/it-tools/`
|
||||
# gets you exactly the same thing.
|
||||
|
||||
env:
|
||||
VITE_VERCEL_ENV: production
|
||||
|
||||
# Runs after the ci workflow passes on a push to the default branch, rather than
|
||||
# repeating its lint, tests, typecheck and build here: the image build compiles
|
||||
# the app anyway, and ci is what decides whether this commit is fit to publish.
|
||||
on:
|
||||
push:
|
||||
workflow_run:
|
||||
workflows: [ci]
|
||||
types: [completed]
|
||||
branches:
|
||||
- chore/all-my-stuffs
|
||||
|
||||
concurrency:
|
||||
# One publish at a time, newest wins: without this, an older run that finishes
|
||||
# last would overwrite the tags with an older commit. ci cancels its own
|
||||
# superseded runs, so these runs arrive in commit order and cancelling the
|
||||
# older one always leaves the newest commit published.
|
||||
group: ${{ github.workflow }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v7.0.0
|
||||
- run: |
|
||||
echo "Before: corepack version => $(corepack --version || echo 'not installed')"
|
||||
npm install -g corepack@latest
|
||||
echo "After : corepack version => $(corepack --version)"
|
||||
corepack enable
|
||||
pnpm --version
|
||||
- uses: actions/setup-node@v6.4.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm i --ignore-scripts
|
||||
|
||||
- name: Run linters
|
||||
run: pnpm lint
|
||||
|
||||
- name: Run unit tests
|
||||
run: pnpm test
|
||||
|
||||
- name: Build the app
|
||||
run: pnpm build
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- ci
|
||||
# Only a successful ci run for a push; a pull request's run must never publish.
|
||||
if: >-
|
||||
github.event.workflow_run.conclusion == 'success' &&
|
||||
github.event.workflow_run.event == 'push'
|
||||
runs-on: ubuntu-26.04-arm
|
||||
steps:
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v6.2.0
|
||||
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
|
||||
with:
|
||||
images: sharevb/it-tools
|
||||
labels: |
|
||||
@@ -52,29 +44,32 @@ jobs:
|
||||
|
||||
# Checkout the repository
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v7.0.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
# The commit ci tested, not whatever the branch points at by now.
|
||||
ref: ${{ github.event.workflow_run.head_sha }}
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v4.4.0
|
||||
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v4.4.0
|
||||
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v4.2.0
|
||||
uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4.2.0
|
||||
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||
|
||||
- name: Build and push (BASE_URL)
|
||||
uses: docker/build-push-action@v7.3.0
|
||||
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
|
||||
@@ -3,51 +3,38 @@ name: Build and Push Docker Image (latest)
|
||||
env:
|
||||
VITE_VERCEL_ENV: production
|
||||
|
||||
# Runs after the ci workflow passes on a push to the default branch, rather than
|
||||
# repeating its lint, tests, typecheck and build here: the image build compiles
|
||||
# the app anyway, and ci is what decides whether this commit is fit to publish.
|
||||
on:
|
||||
push:
|
||||
workflow_run:
|
||||
workflows: [ci]
|
||||
types: [completed]
|
||||
branches:
|
||||
- chore/all-my-stuffs
|
||||
|
||||
concurrency:
|
||||
# One publish at a time, newest wins: without this, an older run that finishes
|
||||
# last would overwrite the tags with an older commit. ci cancels its own
|
||||
# superseded runs, so these runs arrive in commit order and cancelling the
|
||||
# older one always leaves the newest commit published.
|
||||
group: ${{ github.workflow }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v7.0.0
|
||||
- run: |
|
||||
echo "Before: corepack version => $(corepack --version || echo 'not installed')"
|
||||
npm install -g corepack@latest
|
||||
echo "After : corepack version => $(corepack --version)"
|
||||
corepack enable
|
||||
pnpm --version
|
||||
- uses: actions/setup-node@v6.4.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm i --ignore-scripts
|
||||
|
||||
- name: Run linters
|
||||
run: pnpm lint
|
||||
|
||||
- name: Run unit tests
|
||||
run: pnpm test
|
||||
|
||||
- name: Build the app
|
||||
run: pnpm build
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- ci
|
||||
# Only a successful ci run for a push; a pull request's run must never publish.
|
||||
if: >-
|
||||
github.event.workflow_run.conclusion == 'success' &&
|
||||
github.event.workflow_run.event == 'push'
|
||||
runs-on: ubuntu-26.04-arm
|
||||
strategy:
|
||||
matrix:
|
||||
language: ['', 'en']
|
||||
steps:
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v6.2.0
|
||||
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
|
||||
with:
|
||||
images: sharevb/it-tools
|
||||
labels: |
|
||||
@@ -55,29 +42,32 @@ jobs:
|
||||
|
||||
# Checkout the repository
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v7.0.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
# The commit ci tested, not whatever the branch points at by now.
|
||||
ref: ${{ github.event.workflow_run.head_sha }}
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v4.4.0
|
||||
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v4.4.0
|
||||
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v4.2.0
|
||||
uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4.2.0
|
||||
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v7.3.0
|
||||
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
|
||||
@@ -4,49 +4,80 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- chore/all-my-stuffs
|
||||
|
||||
concurrency:
|
||||
# A new push supersedes the previous run on the same ref, so a burst of pushes
|
||||
# costs one run instead of one per push.
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
test:
|
||||
timeout-minutes: 120
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
shard: [1/3, 2/3, 3/3]
|
||||
# Built once and shared: the build output is the same for every browser, so
|
||||
# each test job downloads it instead of spending a minute rebuilding it.
|
||||
build:
|
||||
runs-on: ubuntu-26.04-arm
|
||||
steps:
|
||||
- uses: actions/checkout@v7.0.0
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- run: |
|
||||
echo "Before: corepack version => $(corepack --version || echo 'not installed')"
|
||||
npm install -g corepack@latest
|
||||
echo "After : corepack version => $(corepack --version)"
|
||||
corepack enable
|
||||
pnpm --version
|
||||
|
||||
- uses: actions/setup-node@v6.4.0
|
||||
- name: Setup pnpm and install dependencies
|
||||
uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Get Playwright version
|
||||
id: playwright-version
|
||||
run: echo "PLAYWRIGHT_VERSION=$(jq -r .dependencies.playwright package.json)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --ignore-scripts
|
||||
cache: true
|
||||
|
||||
- name: Build app
|
||||
run: pnpm build
|
||||
|
||||
- name: Upload build output
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: dist
|
||||
path: dist
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
test:
|
||||
needs: build
|
||||
name: test (${{ matrix.browser }})
|
||||
timeout-minutes: 120
|
||||
runs-on: ubuntu-26.04-arm
|
||||
strategy:
|
||||
# Always report every browser, rather than cancelling the rest on the
|
||||
# first failure.
|
||||
fail-fast: false
|
||||
matrix:
|
||||
browser: [chromium, firefox, webkit]
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: Setup pnpm and install dependencies
|
||||
uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0
|
||||
with:
|
||||
cache: true
|
||||
|
||||
- name: Get Playwright version
|
||||
id: playwright-version
|
||||
# The installed version, not the range in package.json: a lockfile bump
|
||||
# inside the same range would otherwise leave the key unchanged and the
|
||||
# cached browsers out of sync with Playwright.
|
||||
run: echo "PLAYWRIGHT_VERSION=$(jq -r .version node_modules/@playwright/test/package.json)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Download build output
|
||||
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
name: dist
|
||||
path: dist
|
||||
|
||||
- name: Restore Playwright browsers from cache
|
||||
uses: actions/cache@v6.1.0
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: ~/.cache/ms-playwright
|
||||
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.PLAYWRIGHT_VERSION }}-${{ hashFiles('**/playwright.config.ts') }}
|
||||
key: ${{ runner.os }}-${{ runner.arch }}-playwright-${{ matrix.browser }}-${{ steps.playwright-version.outputs.PLAYWRIGHT_VERSION }}-${{ hashFiles('**/playwright.config.ts') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.PLAYWRIGHT_VERSION }}-
|
||||
${{ runner.os }}-playwright-
|
||||
${{ runner.os }}-${{ runner.arch }}-playwright-${{ matrix.browser }}-${{ steps.playwright-version.outputs.PLAYWRIGHT_VERSION }}-
|
||||
${{ runner.os }}-${{ runner.arch }}-playwright-${{ matrix.browser }}-
|
||||
|
||||
- name: Install Playwright Browsers
|
||||
run: pnpm exec playwright install --with-deps
|
||||
run: pnpm exec playwright install --with-deps ${{ matrix.browser }}
|
||||
|
||||
- name: Run Playwright tests
|
||||
run: pnpm run test:e2e --shard=${{ matrix.shard }}
|
||||
run: pnpm run test:e2e --project=${{ matrix.browser }}
|
||||
@@ -29,34 +29,34 @@ jobs:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-26.04-arm
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7.0.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v6.4.0
|
||||
- name: Setup pnpm and install dependencies
|
||||
uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: true
|
||||
|
||||
- uses: pnpm/action-setup@v6.0.9
|
||||
name: Install pnpm
|
||||
id: pnpm-install
|
||||
with:
|
||||
run_install: true
|
||||
- name: Run linters
|
||||
run: pnpm lint
|
||||
|
||||
- name: Type check
|
||||
run: pnpm typecheck
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
BASE_URL="/it-tools/" pnpm build
|
||||
cp dist/index.html dist/404.html
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v6.0.0
|
||||
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v5.0.0
|
||||
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
|
||||
with:
|
||||
path: './dist'
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v5.0.0
|
||||
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1
|
||||
@@ -10,11 +10,11 @@ on:
|
||||
|
||||
jobs:
|
||||
docker-release:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-26.04-arm
|
||||
steps:
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v6.2.0
|
||||
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
|
||||
with:
|
||||
images: sharevb/it-tools
|
||||
|
||||
@@ -22,29 +22,29 @@ jobs:
|
||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7.0.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v4.4.0
|
||||
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v4.4.0
|
||||
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v4.2.0
|
||||
uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4.2.0
|
||||
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||
|
||||
- name: Build and push (BASE_URL)
|
||||
uses: docker/build-push-action@v7.3.0
|
||||
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
@@ -62,7 +62,7 @@ jobs:
|
||||
ghcr.io/sharevb/it-tools:${{ env.RELEASE_VERSION}}-baseurl-it-tools
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v7.3.0
|
||||
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
@@ -78,29 +78,25 @@ jobs:
|
||||
ghcr.io/sharevb/it-tools:${{ env.RELEASE_VERSION}}
|
||||
|
||||
github-release:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-26.04-arm
|
||||
needs: docker-release
|
||||
steps:
|
||||
- name: Get release version
|
||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7.0.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- run: |
|
||||
echo "Before: corepack version => $(corepack --version || echo 'not installed')"
|
||||
npm install -g corepack@latest
|
||||
echo "After : corepack version => $(corepack --version)"
|
||||
corepack enable
|
||||
pnpm --version
|
||||
|
||||
- uses: actions/setup-node@v6.4.0
|
||||
- name: Setup pnpm and install dependencies
|
||||
uses: pnpm/setup@fbda4c85fc2e1e08721cd8763afea8f48d60f024 # v3.0.0
|
||||
with:
|
||||
node-version: 24
|
||||
cache: 'pnpm'
|
||||
cache: true
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm i --ignore-scripts
|
||||
- name: Run linters
|
||||
run: pnpm lint
|
||||
|
||||
- name: Type check
|
||||
run: pnpm typecheck
|
||||
|
||||
- name: Build the app
|
||||
run: pnpm build
|
||||
@@ -117,7 +113,7 @@ jobs:
|
||||
echo "$EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v3.0.1
|
||||
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
files: it-tools-${{ env.RELEASE_VERSION }}.zip
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
name: Vercel Preview Deployment
|
||||
env:
|
||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
||||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
||||
VITE_VERCEL_ENV: preview
|
||||
VITE_VERCEL_DEPLOY: true
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- chore/all-my-stuffs
|
||||
pull_request:
|
||||
jobs:
|
||||
Deploy-Preview:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: Install Vercel CLI
|
||||
run: npm install --global vercel@latest
|
||||
- name: Pull Vercel Environment Information
|
||||
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
|
||||
- name: Build Project Artifacts
|
||||
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
|
||||
- name: Deploy Project Artifacts to Vercel
|
||||
run: vercel deploy --prebuilt --archive=tgz --token=${{ secrets.VERCEL_TOKEN }}
|
||||
@@ -1,23 +0,0 @@
|
||||
name: Vercel Production Deployment
|
||||
env:
|
||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
||||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
||||
VITE_VERCEL_ENV: production
|
||||
VITE_VERCEL_DEPLOY: true
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- chore/all-my-stuffs
|
||||
jobs:
|
||||
Deploy-Production:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: Install Vercel CLI
|
||||
run: npm install --global vercel@latest
|
||||
- name: Pull Vercel Environment Information
|
||||
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
|
||||
- name: Build Project Artifacts
|
||||
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
|
||||
- name: Deploy Project Artifacts to Vercel
|
||||
run: vercel deploy --prebuilt --archive=tgz --prod --token=${{ secrets.VERCEL_TOKEN }}
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"printWidth": 120,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all",
|
||||
"arrowParens": "always",
|
||||
"endOfLine": "lf",
|
||||
"ignorePatterns": [
|
||||
"src/libs/**",
|
||||
"dist/**",
|
||||
"coverage/**",
|
||||
"auto-imports.d.ts",
|
||||
"components.d.ts",
|
||||
"pnpm-lock.yaml"
|
||||
]
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
{
|
||||
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
||||
"plugins": ["eslint", "typescript", "oxc", "unicorn", "import", "promise", "vue", "vitest"],
|
||||
"categories": {
|
||||
"correctness": "error"
|
||||
},
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2026": true
|
||||
},
|
||||
"globals": {
|
||||
"process": "readonly"
|
||||
},
|
||||
"ignorePatterns": [
|
||||
"src/libs/**",
|
||||
"dist/**",
|
||||
"coverage/**",
|
||||
"auto-imports.d.ts",
|
||||
"components.d.ts"
|
||||
],
|
||||
"rules": {
|
||||
"eslint/curly": ["error", "all"],
|
||||
"typescript/no-use-before-define": [
|
||||
"error",
|
||||
{ "allowNamedExports": true, "functions": false }
|
||||
],
|
||||
"eslint/no-restricted-imports": [
|
||||
"error",
|
||||
{
|
||||
"paths": [
|
||||
{
|
||||
"name": "@vueuse/core",
|
||||
"importNames": ["useClipboard"],
|
||||
"message": "Please use local useCopy from src/composable/copy.ts instead of useClipboard."
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"no-undef": "off",
|
||||
"eslint/no-unused-vars": [
|
||||
"error",
|
||||
{ "caughtErrors": "none", "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }
|
||||
],
|
||||
"eslint/no-useless-escape": "off",
|
||||
"import/default": "off",
|
||||
"vue/no-dupe-keys": "off",
|
||||
"vitest/valid-expect": "off",
|
||||
"vitest/expect-expect": "off",
|
||||
"vitest/require-to-throw-message": "off"
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["**/*.test.ts", "**/*.spec.ts", "**/*.e2e.spec.ts"],
|
||||
"env": { "vitest": true }
|
||||
},
|
||||
{
|
||||
"files": ["**/calendar-converter/calendar-converter.service.ts"],
|
||||
"rules": {
|
||||
"eslint/no-unused-vars": "off",
|
||||
"oxc/erasing-op": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
+153
@@ -2,6 +2,159 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## Version 2026.11.22
|
||||
|
||||
### Features
|
||||
- **xml-diff**: add XML diff tool (e8f0677)
|
||||
- **new tool**: Paste Image (0295223)
|
||||
- **new tool**: Whitespace cleaner tool (8974b30)
|
||||
- **new tool**: CLI Banner Generator (6e021e9)
|
||||
- **new tools**: 4-20 mA, 0-10 V and analog scaling converters (#596) (b5eace8)
|
||||
- **new tool**: Fraction Decimal Converter (41297c8)
|
||||
- **new tool**: Sound Tester (f122baf)
|
||||
|
||||
### Bug fixes
|
||||
- update nginx for CVE (5bbc672)
|
||||
- **percentage-calculator**: clear the result when an input is cleared (7632d99)
|
||||
- **extract desc script**: handle formatting of long lines (83d7d33)
|
||||
- **Fortune Wheel**: better color choosing and UI enhancement (8d13f0a)
|
||||
- **hash-text**: refresh added hashes when digest encoding changes (#594) (e775893)
|
||||
- keep the language dropdown scrollable within the viewport (#592) (324a6be)
|
||||
- **Regex Memo**: fix Escaping table formatting (ec33d7d)
|
||||
|
||||
### Continuous integration
|
||||
- fix e2e (d10b89b)
|
||||
- disable deploy on renovate bot PR because it exceeds Vercel free plan limits (231930d)
|
||||
|
||||
### Chores
|
||||
- **deps**: update nginxinc/nginx-unprivileged:stable-alpine docker digest to f5116ed (#590) (47943c7)
|
||||
|
||||
### I18n
|
||||
- extract and translate remaining (1d77ed3)
|
||||
- extract and translated remaining (8f94ed3)
|
||||
|
||||
## Version 2026.10.25
|
||||
|
||||
### Features
|
||||
- **json-viewer, yaml-viewer, currency-converter, geo-coordinates-converter**: support intranet mirrors (3af8e4a)
|
||||
- **gitignore-generator, gitattributes-generator**: fall back to a bundled template snapshot (81c1201)
|
||||
- **translator, remove-background, math-ocr, ocr-image, gif-to-mp4**: ship runtimes with the app (d53e745)
|
||||
- **settings**: add an offline mode that hides internet-only tools (4a80283)
|
||||
- **zpool-memo**: add localized content and recategorize (f196182)
|
||||
|
||||
### Bug fixes
|
||||
- **dns-query, gitattributes-generator**: hide dns-query offline, pin commands to the snapshot (788d4fd)
|
||||
- **explainshell, ocr-image**: honour the configured mirrors (8ec5590)
|
||||
- **countdown, cron-alarm, time-alarm**: resolve Beep.mp3 against the app base (94c0bbf)
|
||||
- **markdown-editor, unicode-formatter, pomodoro-timer**: bundle editor extensions and fonts (b536f04)
|
||||
- **visualsubnetcalc, zpool-calc**: escape user data before inserting HTML (de40fc7)
|
||||
- **scripts**: make extract-tools-desc quote matching linear (a891be1)
|
||||
- **database-builder**: quote names and passwords in generated SQL (1b8d487)
|
||||
- **random**: use crypto.getRandomValues for generated secrets (0203c23)
|
||||
- **layout**: escape every bracket and paren in footer package links (d785329)
|
||||
- **markdown**: escape backslashes in generated table cells (3872432)
|
||||
- **json-viewer**: unescape JSON strings in a single pass (9b65547)
|
||||
- **objgen**: comment detection and whitespace stripping (b688f52)
|
||||
- **docker**: serve precompressed static assets (#583) (4e5c0fd)
|
||||
|
||||
### Refactoring
|
||||
- **turndown**: remove text-node escape rules that never run (f1b20c7)
|
||||
|
||||
### Build system
|
||||
- **deps**: add the assets offline mode ships, drop unused currency and ffmpeg helpers (ea30976)
|
||||
|
||||
### I18n
|
||||
- add Traditional Chinese (zh-TW) locale (#587) (d6e478c)
|
||||
- **en, zh**: describe bundled assets, mirrors and snapshots (6241fa6)
|
||||
- **zh**: review the Simplified Chinese translation (#584) (bb00dcb)
|
||||
- rewrite Italian locale with human-quality translations (#582) (3e7f845)
|
||||
- update translations for iptables and fstab generator tools (cba443d)
|
||||
|
||||
### Documentation
|
||||
- **readme**: document offline mode and the mirror settings (b64d2a1)
|
||||
- **zpool-memo**: reformat vdev type table (e179bd5)
|
||||
- **locales**: improve zh UFW generator translations (44f1298)
|
||||
|
||||
## Version 2026.09.27
|
||||
|
||||
### Features
|
||||
- **Timezone Converter**: add POSIX string filterable list (7fc4b79)
|
||||
- **JSON Editor**: store data and add an auto height option (0f4c7b1)
|
||||
- **new tool**: Restic Command Generator (#573) (c96fd39)
|
||||
- **Keys Generator**: add fingerprint (bc1d9a3)
|
||||
- **new tool**: EPC QR Code Generator (c80a08b)
|
||||
- **new tool**: URL Redirection Checker (0039bd7)
|
||||
- **QRCode Generator**: add embeddable link and cropy dataurl (39c616f)
|
||||
- **docker**: serve the app from any subpath with a runtime BASE_URL (#565) (0a1f5dc)
|
||||
- add i18n internationalization for memo and cheatsheet (#552) (04cfee6)
|
||||
- mermaid live preview (#548) (db3a344)
|
||||
- **new tool**: Markdown Format Converter (#488) (671e8a1)
|
||||
- **k8s-memo**: add i18n support for memo content (#546) (db9ac4e)
|
||||
- **common-regex-memo**: add i18n support for memo content (#547) (bc12798)
|
||||
- add warning about need of external self hosted for related tools (6e89d3d)
|
||||
- useNetworkUtilsConfig and basic auth for all tools requiring external docker services (65955d9)
|
||||
- **Math OCR**: replace MathJAX by Katex (b1d3849)
|
||||
- add Cross Origin Isolation (HTTP Headers) (c4f7ded)
|
||||
- **Sitemap**: add HOSTNAME env var to generate a sitemap (96a2079)
|
||||
- Integer Base Converter space separator support (#481) (a2d6961)
|
||||
- **new tool**: Ping (aa515d9)
|
||||
- **IBAN Validator and Parser**: add bank infos (0620f57)
|
||||
|
||||
### Bug fixes
|
||||
- c-link to vs href (62ab0bf)
|
||||
- **deps**: move the two remaining deprecated direct dependencies onto supported versions (#559) (d39255a)
|
||||
- **docker**: run on read-only filesystems, IPv6-less hosts and cpu-limited containers (#556) (8b7bc0a)
|
||||
- **i18n**: tool search in current language and handle switching (e5a2017)
|
||||
- **Code Block Copyable**: enable lineWrapping (be4d225)
|
||||
- **Units Converter**: make units translatable (66e2ac5)
|
||||
- **Units Converter**: ensure label fits (fb6cc73)
|
||||
- **Regex Tester**: navigation bug due to shaddowroot (3864323)
|
||||
- **layout**: prevent horizontal page overflow with wide code content (#483) (f1358d5)
|
||||
- allows cross origin isolation for tools with img and iframe (db32bb0)
|
||||
- **i18n**: some text (e1de52b)
|
||||
- **Dockerfile**: Add source label to Dockerfile (175c860)
|
||||
- **Cron Expression Generator**: handle input cron and standard only (fe2766e)
|
||||
|
||||
### Performance
|
||||
- **bundle**: improve initial load + loading of tools (#575) (641fa85)
|
||||
|
||||
### Refactoring
|
||||
- **websocket-tester**: use the native WebSocket instead of w-websocket-client (#558) (903ffb8)
|
||||
|
||||
### Continuous integration
|
||||
- pnpm 12, pnpm/setup v3, faster and pinned CI, single Vercel deploy workflow (#577) (da38faa)
|
||||
- rework the test and lint toolchain — per-browser E2E, scoped jsdom, type-aware oxlint (#561) (ec740dd)
|
||||
- use pnpm/setup for pnpm and Node setup, pin Node in package.json (#560) (fbc7d47)
|
||||
|
||||
### Chores
|
||||
- fix release script (51cb093)
|
||||
- update deps (90b7793)
|
||||
- remove fm:check ypass (a049d1c)
|
||||
- global code formatting (bc44870)
|
||||
- **deps**: replace the five deprecated packages from the dependency dashboard (#557) (5e4972e)
|
||||
- **deps**: update dependency @playwright/test to ^1.62.0 (#511) (9bc3cb7)
|
||||
- **deps**: update type packages with their dependencies (#452) (db050b2)
|
||||
- update deps (23dc0d4)
|
||||
|
||||
### Other
|
||||
- Restructure and enhance cheat sheets for improved readability (#566) (5bf94bc)
|
||||
- add proxmox helper script (#568) (a5607e0)
|
||||
- Enhance Docker Swarm documentation (#564) (002a211)
|
||||
- Fix regex to clean base64 data URI (#563) (2912cf3)
|
||||
- Optimize the Chinese translationUpdate zh.yml (#549) (69f5084)
|
||||
- Update FUNDING.yml to include Buy Me a Coffee (c82794a)
|
||||
- Fix French translations in fr.yml (#551) (07102a6)
|
||||
- Optimize Chinese translation (#487) (27ab891)
|
||||
- Translate another docker cheatsheets to zh-cn (#479) (c105c1e)
|
||||
|
||||
### I18n
|
||||
- extract and translate remaining (6aa2e1c)
|
||||
- translate remaining (e725356)
|
||||
- translate remaining (bbc819f)
|
||||
|
||||
### Doc
|
||||
- add a docker compose sample with all related services (2abda9b)
|
||||
|
||||
## Version 2026.07.11
|
||||
|
||||
### Features
|
||||
|
||||
+42
-7
@@ -1,5 +1,5 @@
|
||||
# build stage
|
||||
FROM --platform=$BUILDPLATFORM node:24-alpine AS build-stage
|
||||
FROM --platform=$BUILDPLATFORM node:24-alpine@sha256:ebfe2f90462722a7a4de65e91990e97fe0d401c70e0e762c5b53302f905ec1c1 AS build-stage
|
||||
# Set environment variables for non-interactive npm installs
|
||||
ENV NPM_CONFIG_LOGLEVEL=warn
|
||||
ENV CI=true
|
||||
@@ -11,28 +11,63 @@ WORKDIR /app
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
COPY patches patches
|
||||
COPY stubs stubs
|
||||
RUN npm install -g pnpm@11 && pnpm i --ignore-scripts --frozen-lockfile
|
||||
RUN npm install -g pnpm@12.6.0 && pnpm i --ignore-scripts --frozen-lockfile
|
||||
COPY . .
|
||||
ARG BASE_URL
|
||||
ENV BASE_URL=${BASE_URL}
|
||||
# Deliberately no BASE_URL here: the bundle is built path-agnostic (relative asset URLs
|
||||
# plus a `<base href="/">` in index.html) so that one image can be served from any
|
||||
# subpath. The path is a runtime setting instead -- see the BASE_URL environment variable
|
||||
# on the production stage below.
|
||||
ARG VITE_AVAILABLE_LOCALES
|
||||
ENV VITE_AVAILABLE_LOCALES=${VITE_AVAILABLE_LOCALES}
|
||||
ENV VITE_VERCEL_ENV=production
|
||||
RUN pnpm build
|
||||
# Precompress hashed assets once instead of compressing each response at runtime.
|
||||
RUN pnpm build \
|
||||
&& find dist/assets -type f \( -name '*.js' -o -name '*.mjs' -o -name '*.css' -o -name '*.wasm' \) \
|
||||
-exec gzip -9 -n -k {} +
|
||||
|
||||
# production stage
|
||||
FROM nginxinc/nginx-unprivileged:stable-alpine AS production-stage
|
||||
FROM nginx/nginx-unprivileged:alpine AS production-stage
|
||||
|
||||
LABEL maintainer="ShareVB <sharevb@gmail.com>" \
|
||||
org.opencontainers.image.authors="ShareVB <sharevb@gmail.com>"
|
||||
LABEL org.opencontainers.image.source=github.com/sharevb/it-tools
|
||||
|
||||
ENV VITE_VERCEL_ENV=production
|
||||
ARG BASE_URL
|
||||
|
||||
# The path the app is served under. Override it at run time -- `docker run -e
|
||||
# BASE_URL=/it-tools/`, `environment: BASE_URL: /it-tools/` in a compose file -- and nginx
|
||||
# rewrites the `<base href>` in index.html on the way out; nothing is baked in. The build
|
||||
# arg only moves the default, for anyone who prefers to ship an image that is preconfigured
|
||||
# for a subpath. See docker-entrypoint.d/18-resolve-base-url.envsh and nginx.conf.
|
||||
ARG BASE_URL=/
|
||||
ENV BASE_URL=${BASE_URL}
|
||||
|
||||
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
||||
|
||||
COPY nginx.conf /etc/nginx/templates/default.conf.template
|
||||
COPY docker-entrypoint.d/ /docker-entrypoint.d/
|
||||
ENV PORT=8080
|
||||
|
||||
# nginx defaults to `worker_processes auto`, which counts the host's cores and
|
||||
# ignores the container's cpu limit. On a large host that is hundreds of
|
||||
# workers in a small container: `docker run -m 192m` is enough to get the
|
||||
# image OOM-killed on startup. Let the entrypoint size the pool from the cgroup
|
||||
# cpu quota instead. Uncapped containers still get one worker per core.
|
||||
ENV NGINX_ENTRYPOINT_WORKER_PROCESSES_AUTOTUNE=1
|
||||
|
||||
# Render the template once here as well. The entrypoint normally re-renders it
|
||||
# at startup, so a custom $PORT keeps working, but it cannot do so on a
|
||||
# read-only filesystem (see docker-entrypoint.d/19-skip-envsubst-if-readonly.envsh).
|
||||
# Without this the image would fall back to the stock welcome config from the
|
||||
# base image: no SPA fallback, so deep links 404 on refresh, and no COOP/COEP,
|
||||
# so the WebAssembly-backed tools stop working.
|
||||
# Sourcing the entrypoint's own resolver keeps the baked-in BASE_URL normalised and
|
||||
# validated exactly the way a runtime one would be.
|
||||
RUN . /docker-entrypoint.d/18-resolve-base-url.envsh \
|
||||
&& envsubst '${PORT} ${BASE_URL} ${BASE_URL_REGEX} ${BASE_URL_NO_SLASH_REGEX}' \
|
||||
< /etc/nginx/templates/default.conf.template \
|
||||
> /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE $PORT
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
@@ -1,14 +1,27 @@
|
||||
## BREAKING CHANGE for Container Image
|
||||
|
||||
Since the *base image* is now `nginx-unpriviledged` the container will now listen to port **8080** and not 80. So you need to update your port mapping, i.e. from `8080:80` to `8080:8080`.
|
||||
Since the _base image_ is now `nginx-unpriviledged` the container will now listen to port **8080** and not 80. So you need to update your port mapping, i.e. from `8080:80` to `8080:8080`.
|
||||
|
||||
You can override listening port using environment variable `PORT` (docker option `-e PORT=8888`).
|
||||
|
||||
You can serve the app from a subfolder using environment variable `BASE_URL` (docker option
|
||||
`-e BASE_URL=/it-tools/`), without rebuilding the image -- see
|
||||
[Host in a subfolder](#host-in-a-subfolder-it-tools).
|
||||
|
||||
If the container needs to listen to IPv6, it needs to be enabled: https://serverfault.com/questions/1147296/how-to-enable-ipv6-on-ubuntu-20-04. Alternatively, you can mount your own `nginx.conf` own using docker option `-v "./nginx.conf:/etc/nginx/templates/default.conf.template"` (with `listen [::]:8080;` removed)
|
||||
|
||||
## Proxmox Install
|
||||
|
||||
Run the command below in the Proxmox VE Shell
|
||||
|
||||
```bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/alpine-it-tools.sh)"```
|
||||
|
||||
## Build requirements
|
||||
|
||||
**To build this project**, you need around **16GB** (as it builds on Github workers). Below, you will get some `out of memory` or `node allocation failed`.
|
||||
**To build this project**, around **8GB** of RAM is enough. Measured on a 4-core
|
||||
machine, `pnpm build` peaks at roughly 6.5GB of system memory and completes on
|
||||
Node's default heap — most of the work happens inside rolldown, in Rust, rather
|
||||
than on the JavaScript heap.
|
||||
|
||||
## PR Welcome
|
||||
|
||||
@@ -23,6 +36,7 @@ Some tools like PGP encryption rely on WebCrypto API that is only available in H
|
||||
So even on internal installations, you should enable HTTPS using Let's Encrypt using DNS Challenge
|
||||
|
||||
Some docs about DNS Challenge:
|
||||
|
||||
- https://medium.com/@life-is-short-so-enjoy-it/homelab-nginx-proxy-manager-setup-ssl-certificate-with-domain-name-in-cloudflare-dns-732af64ddc0b
|
||||
- https://doc.traefik.io/traefik/user-guides/docker-compose/acme-dns/
|
||||
- https://medium.com/@svenvanginkel/traefik-letsencrypt-dns01-challenge-with-ovhcloud-52f2a2c6d08a
|
||||
@@ -68,6 +82,12 @@ docker run --pull always --restart unless-stopped -p 8080:8080 sharevb/it-tools:
|
||||
|
||||
Other existing docker tags: `latest-en` (english only)
|
||||
|
||||
Container builds precompress JavaScript, CSS, and WebAssembly files in `dist/assets`.
|
||||
Nginx serves the `.gz` sidecars when clients accept gzip, including requests forwarded
|
||||
by reverse proxies, and otherwise serves the original files. Compression happens once
|
||||
at build time rather than on every request. HTML remains uncompressed so runtime
|
||||
`BASE_URL` rewriting continues to work.
|
||||
|
||||
## Use in Docker Compose file
|
||||
|
||||
```yml
|
||||
@@ -101,12 +121,18 @@ WantedBy=multi-user.target default.target
|
||||
Restart=always
|
||||
```
|
||||
|
||||
## Use with companion Self Hosted docker services
|
||||
|
||||
Some tools requires additional docker services: HTTPS/DNS tools/Ping, HTML to PDF, Docker Image Download, Multi Links Download, Short Url Expander and TCP/UDP Port tester.
|
||||
|
||||
See complete example here: [docker-with-services](https://github.com/sharevb/it-tools/tree/chore/all-my-stuffs/docker-with-services)
|
||||
|
||||
## Filter tools and add home custom content
|
||||
|
||||
You can add custom content in Home page by mounting a `home.custom.md` in `/usr/share/nginx/html`.
|
||||
|
||||
You can filter available tools by mounting `tools-filter.json` in `/usr/share/nginx/html`. It can contains the following filtering regex:
|
||||
|
||||
```json
|
||||
{
|
||||
"excludeCategoryFilterRegex": "",
|
||||
@@ -115,9 +141,10 @@ You can filter available tools by mounting `tools-filter.json` in `/usr/share/ng
|
||||
"includeToolsFilterRegex": ""
|
||||
}
|
||||
```
|
||||
|
||||
Category matches on category (English) names ; Tools matches on tools path/url.
|
||||
|
||||
See [docker-tools-filter-and-home-content](https://github.com/sharevb/it-tools)
|
||||
See [docker-tools-filter-and-home-content](https://github.com/sharevb/it-tools/tree/chore/all-my-stuffs/docker-tools-filter-and-home-content)
|
||||
|
||||
## Add custom external tools
|
||||
|
||||
@@ -144,13 +171,16 @@ You can add custom external tools (href or markdownContent) by mounting a `exter
|
||||
]
|
||||
```
|
||||
|
||||
See [docker-tools-filter-and-home-content](https://github.com/sharevb/it-tools)
|
||||
See [docker-tools-filter-and-home-content](https://github.com/sharevb/it-tools/tree/chore/all-my-stuffs/docker-tools-filter-and-home-content)
|
||||
|
||||
## Setting default tools parameters / default UI language at runtime
|
||||
|
||||
For a complete sample, see [docker-with-services](https://github.com/sharevb/it-tools/tree/chore/all-my-stuffs/docker-with-services).
|
||||
|
||||
You can set default tool parameters by mounting a `tools-settings.json` in `/usr/share/nginx/html`.
|
||||
|
||||
It is a two level json, with the first level being for `tool name` and the second level for `parameter name`:
|
||||
|
||||
```json
|
||||
{
|
||||
"regex-tester": {
|
||||
@@ -162,7 +192,9 @@ It is a two level json, with the first level being for `tool name` and the secon
|
||||
```
|
||||
|
||||
You can find `tool name` and `parameter name` in the tools source code `src/tools` subfolder :
|
||||
|
||||
- example pattern for `const global = useQueryParamOrStorage({ storageName: 'regex-tester:g', name: 'global', defaultValue: true });`:
|
||||
|
||||
```json
|
||||
{
|
||||
"regex-tester": {
|
||||
@@ -170,7 +202,9 @@ You can find `tool name` and `parameter name` in the tools source code `src/tool
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- example pattern for `const value = useQueryParam({ tool: 'barcode-gen', name: 'text', defaultValue: '123456789' });`:
|
||||
|
||||
```json
|
||||
{
|
||||
"barcode-gen": {
|
||||
@@ -178,7 +212,9 @@ You can find `tool name` and `parameter name` in the tools source code `src/tool
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- example pattern for `const width = useITStorage('ascii-text-drawer:width', 80);`:
|
||||
|
||||
```json
|
||||
{
|
||||
"ascii-text-drawer": {
|
||||
@@ -188,12 +224,52 @@ You can find `tool name` and `parameter name` in the tools source code `src/tool
|
||||
```
|
||||
|
||||
To define the default UI language, add a `default_locale` key to json:
|
||||
|
||||
```json
|
||||
{
|
||||
"default_locale": "fr"
|
||||
}
|
||||
```
|
||||
|
||||
## Offline / air-gapped deployments
|
||||
|
||||
Fonts, editor extensions, the ffmpeg core, the ONNX runtime, the Tesseract OCR engine and its English and Simplified Chinese language data ship with the app, so these never come from a third-party CDN. The large ones are only downloaded when their tool is opened, and are left out of the PWA precache.
|
||||
|
||||
On a network without internet access, add `"offline": true` to `tools-settings.json`. Tools that only work with internet are then hidden (my-ip, ip-geo-location, dns-query, dns-queries, dnsbl-checker, dns-propagation-tester, online-wiktionary, iana-whois-checker), and tools with a bundled fallback switch to it:
|
||||
|
||||
- gitignore-generator and gitattributes-generator use a template snapshot bundled at build time (also used online when GitHub can't be reached). Refresh it with `pnpm script:update:git-templates`.
|
||||
- ocr-image offers only the bundled languages.
|
||||
- JSON/YAML schema validation offers only a custom schema (pasted, or a URL you enter).
|
||||
- geo-coordinates-converter converts coordinates without showing a map.
|
||||
|
||||
Some tools work offline once you point them at an intranet mirror; without one, they are hidden in offline mode. The mirrors can also be used online:
|
||||
|
||||
```json
|
||||
{
|
||||
"offline": true,
|
||||
"transformers": { "models-url": "https://intranet.example/hf-mirror/" },
|
||||
"ocr-image": { "lang-url": "https://intranet.example/tessdata/" },
|
||||
"json-schemas": { "catalog-url": "https://intranet.example/schemastore/api/json/catalog.json" },
|
||||
"currency-converter": { "url": "https://intranet.example/currency-api/" },
|
||||
"geo-coordinates-converter": {
|
||||
"tile-url": "https://tiles.intranet.example/{z}/{x}/{y}.png",
|
||||
"tile-attribution": "© OpenStreetMap contributors"
|
||||
},
|
||||
"explainchain": { "url": "https://explainshell.intranet.example" }
|
||||
}
|
||||
```
|
||||
|
||||
| Setting | Used by | Expected content |
|
||||
| --- | --- | --- |
|
||||
| `transformers.models-url` | translator, remove-background, math-ocr | A mirror of the Hugging Face model repos with the same layout: `<url>/<org>/<model>/resolve/main/<file>`, e.g. `Xenova/opus-mt-en-fr/resolve/main/onnx/encoder_model_quantized.onnx`. Relative URLs resolve against the app. |
|
||||
| `ocr-image.lang-url` | ocr-image | A directory of `<lang>.traineddata.gz` files (the `4.0.0_best_int` variant from the `@tesseract.js-data/<lang>` npm packages). The path may contain a `{lang}` placeholder, e.g. `https://intranet.example/npm/@tesseract.js-data/{lang}/4.0.0_best_int` for a mirror of jsDelivr. |
|
||||
| `json-schemas.catalog-url` | json-viewer, yaml-viewer, json-editor, json-linter | A copy of the [SchemaStore](https://www.schemastore.org) catalog. The schema URLs listed in it must be reachable too. |
|
||||
| `currency-converter.url` | currency-converter | A mirror of the `@fawazahmed0/currency-api` npm package, serving `v1/currencies/<code>.json`. |
|
||||
| `geo-coordinates-converter.tile-url` | geo-coordinates-converter | A Leaflet tile URL template; `tile-attribution` is optional. |
|
||||
| `explainchain.url` | explainshell | A self-hosted [explainshell](https://github.com/idank/explainshell). |
|
||||
|
||||
The tools that use the [companion self-hosted services](#use-with-companion-self-hosted-docker-services) stay available in offline mode and work against intranet targets.
|
||||
|
||||
## To build using a custom default language:
|
||||
|
||||
```
|
||||
@@ -201,28 +277,39 @@ docker build -t it-tools-fr --build-arg VITE_LANGUAGE=fr .
|
||||
docker run -d --name it-tools-fr --restart unless-stopped -p 8080:8080 it-tools-fr
|
||||
```
|
||||
|
||||
## Build container image for a custom subfolder
|
||||
## Host in a subfolder (`/it-tools/`)
|
||||
|
||||
According to https://github.com/sharevb/it-tools/pull/461#issuecomment-1602506049 and https://github.com/CorentinTh/it-tools/pull/461:
|
||||
```
|
||||
docker build -t it-tools --build-arg BASE_URL="/my-folder/" .
|
||||
docker run -d --name it-tools --restart unless-stopped -p 8080:8080 it-tools
|
||||
The container serves the app from whatever path you point `BASE_URL` at. Nothing is baked
|
||||
into the image, so the regular `latest` image works for any subfolder -- no rebuild, no
|
||||
subfolder-specific tag:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
it-tools:
|
||||
image: ghcr.io/sharevb/it-tools:latest
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
BASE_URL: /it-tools/
|
||||
ports:
|
||||
- 8080:8080
|
||||
```
|
||||
|
||||
Then if you go to `http://localhost:8080` you'll get a blank page, but opening the DevTools (& refreshing) you'll notice in the Network tab that the app is trying to fetch assets from `/my-folder/...`
|
||||
or `docker run -d --name it-tools -e BASE_URL=/it-tools/ -p 8080:8080 ghcr.io/sharevb/it-tools:latest`.
|
||||
|
||||
So you would need to put another server in front of it, like [Nginx Proxy Manager](https://nginxproxymanager.com/), [Traefik](https://traefik.io/traefik/), [caddy](https://caddyserver.com/) etc. Then setup a reverse proxy pass using `/my-folder`
|
||||
`BASE_URL` accepts `it-tools`, `/it-tools` and `/it-tools/` alike; the default is `/`.
|
||||
|
||||
## Docker compose for hosting in a `/it-tools/` subfolder
|
||||
You still want a reverse proxy in front -- [Nginx Proxy Manager](https://nginxproxymanager.com/),
|
||||
[Traefik](https://traefik.io/traefik/), [caddy](https://caddyserver.com/) etc. -- passing
|
||||
`/it-tools/` through to the container. It does not matter whether the proxy strips the
|
||||
prefix before forwarding (`proxy_pass http://it-tools:8080/;`) or passes it on as-is
|
||||
(`proxy_pass http://it-tools:8080;`): the container handles both.
|
||||
|
||||
For `/it-tools/` subfolder, you can use `baseurl-it-tools` tag.
|
||||
|
||||
See [sample of docker-compose.yml and nginx.conf](https://github.com/sharevb/it-tools/tree/chore/all-my-stuffs/docker-subfolder-sample), this docker image needs to have another reverse proxy in front of it, like [Nginx Proxy Manager](https://nginxproxymanager.com/), [Traefik](https://traefik.io/traefik/), [caddy](https://caddyserver.com/) etc.
|
||||
|
||||
Setup a reverse proxy pass using `/it-tools/`. And you should be able to access it-tools in `/it-tools/` of your server.
|
||||
|
||||
An example of nginx reverse proxy configuration is available at: https://github.com/sharevb/it-tools/tree/chore/all-my-stuffs/docker-subfolder-sample
|
||||
One thing only the proxy can do, in the stripping setup: `/it-tools` without the trailing
|
||||
slash never reaches the container, so redirect it there -- the sample's
|
||||
`location /it-tools { return 301 /it-tools/; }`. When the prefix is forwarded instead, the
|
||||
container does that redirect itself.
|
||||
|
||||
See the [sample docker-compose.yml and nginx.conf](https://github.com/sharevb/it-tools/tree/chore/all-my-stuffs/docker-subfolder-sample).
|
||||
To run the sample:
|
||||
|
||||
```bash
|
||||
@@ -231,7 +318,15 @@ cd it-tools/docker-subfolder-sample/
|
||||
docker compose up
|
||||
```
|
||||
|
||||
Then navigate to http://localhost:8080/it-tools/
|
||||
Then navigate to http://localhost/it-tools/
|
||||
|
||||
Two things worth knowing:
|
||||
|
||||
- Building with `--build-arg BASE_URL=/it-tools/` still works, but it now only changes the
|
||||
image's *default* -- the environment variable still wins at run time.
|
||||
- On a read-only root filesystem the config template cannot be re-rendered at startup, so
|
||||
`BASE_URL` (like `PORT`) has no effect unless `/etc/nginx/conf.d` is writable -- mount a
|
||||
tmpfs or an emptyDir there. The container says so in its log.
|
||||
|
||||
## To build using a custom folder:
|
||||
|
||||
@@ -247,14 +342,15 @@ Then navigate to http://localhost:8080/it-tools/
|
||||
|
||||
Assuming you're already hosting it-tools behind a reverse proxy, you can configure forward-auth and enforce authentication from the reverse proxy
|
||||
|
||||
* [Official guides](https://docs.goauthentik.io/docs/add-secure-apps/providers/proxy/server_nginx) with nginx. Guides with other reverse proxy setups are available
|
||||
* [Step-by-step setup guide with nginx-proxy-manager](https://geekscircuit.com/set-up-authentik-sso-with-nginx-proxy-manager/)
|
||||
- [Official guides](https://docs.goauthentik.io/docs/add-secure-apps/providers/proxy/server_nginx) with nginx. Guides with other reverse proxy setups are available
|
||||
- [Step-by-step setup guide with nginx-proxy-manager](https://geekscircuit.com/set-up-authentik-sso-with-nginx-proxy-manager/)
|
||||
|
||||
(thanks @jogerj)
|
||||
|
||||
## Deploy as LXC container
|
||||
|
||||
In Proxmox VE, you can use docker image directly:
|
||||
|
||||
```bash
|
||||
sudo lxc-create -n sharevb-it-tools -t oci -- --url docker://ghcr.io/sharevb/it-tools:latest
|
||||
```
|
||||
@@ -318,9 +414,28 @@ pnpm build
|
||||
### Run Unit Tests with [Vitest](https://vitest.dev/)
|
||||
|
||||
```sh
|
||||
pnpm test
|
||||
pnpm test:unit
|
||||
```
|
||||
|
||||
### Run End-to-End Tests with [Playwright](https://playwright.dev/)
|
||||
|
||||
Playwright starts `pnpm preview` itself, so build first:
|
||||
|
||||
```sh
|
||||
pnpm build
|
||||
pnpm test:e2e
|
||||
```
|
||||
|
||||
To iterate against the dev server instead, leave `pnpm dev` running and point
|
||||
the tests at it. Playwright then leaves the server alone:
|
||||
|
||||
```sh
|
||||
E2E_BASE_URL=http://localhost:5173 pnpm test:e2e
|
||||
```
|
||||
|
||||
The dev server compiles routes on demand, so a first run against a cold one can
|
||||
blow past the assertion timeouts. Open the pages once, or just run it again.
|
||||
|
||||
### Lint with [Oxlint](https://oxc.rs/docs/guide/usage/linter)
|
||||
|
||||
```sh
|
||||
@@ -355,11 +470,11 @@ It will create a directory in `src/tools` with the correct files. You will need
|
||||
|
||||
Local installation required installing first: `python3 make g++`
|
||||
|
||||
| Container Image | Local Installation |
|
||||
|-----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
|
||||
| Container Image | Local Installation |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| GitHub Container Registry: <span title="triple click me!">`ghcr.io/sharevb/it-tools:latest`</span><br/>Docker Hub: <span title="triple click me!">`sharevb/it-tools:latest`</span> | <span title="triple click me!">`sudo apt-get install python3 make g++ && git clone -b chore/all-my-stuffs https://github.com/sharevb/it-tools.git && cd it-tools/ && pnpm i --ignore-scripts && pnpm dev`</span> |
|
||||
| replace your current image with this image | copy & paste oneliner (from github repo) |
|
||||
| You may need to clear cache and hard reload to get new features loading | Installing packages for the first time may take some time; please wait until it finishes |
|
||||
| replace your current image with this image | copy & paste oneliner (from github repo) |
|
||||
| You may need to clear cache and hard reload to get new features loading | Installing packages for the first time may take some time; please wait until it finishes |
|
||||
|
||||
<picture>
|
||||
<source srcset="./.github/logo-dark.png" media="(prefers-color-scheme: light)">
|
||||
@@ -369,4 +484,4 @@ Local installation required installing first: `python3 make g++`
|
||||
|
||||
## License
|
||||
|
||||
This project is under the [GNU GPLv3](LICENSE).
|
||||
This project is under the [GNU GPLv3](LICENSE).
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
# vim:sw=4:ts=4:et
|
||||
#
|
||||
# BASE_URL is the path the app is served under: `/` (the default) for a deployment at the
|
||||
# root of a domain, `/it-tools/` for one behind a reverse proxy that mounts it on a
|
||||
# subpath. It is a runtime setting, not a build one -- the image ships assets that work at
|
||||
# any path, and nginx.conf rewrites the `<base href>` in index.html per request.
|
||||
#
|
||||
# Normalise it here, once, before 20-envsubst-on-templates.sh renders the config:
|
||||
#
|
||||
# - accept `it-tools`, `/it-tools` and `/it-tools/` alike, always emit `/it-tools/`.
|
||||
# A missing trailing slash would otherwise silently move the app one directory up,
|
||||
# because that is how the browser resolves relative URLs against `<base href>`.
|
||||
# - reject anything that is not a plain path. The value is interpolated into an HTML
|
||||
# attribute and into an nginx regex, so a stray quote or `..` is worth catching here
|
||||
# rather than letting it land in the served page.
|
||||
#
|
||||
# Sourced, not executed, so the export reaches the envsubst step.
|
||||
|
||||
_base_url=$(printf '%s' "${BASE_URL:-/}" | sed -e 's#^/*#/#' -e 's#/*$#/#')
|
||||
|
||||
case "$_base_url" in
|
||||
# `/` itself, or `/segment/segment/` made of unreserved URL characters.
|
||||
/) ;;
|
||||
*/../* | *//*)
|
||||
_base_url_invalid=1
|
||||
;;
|
||||
*[!A-Za-z0-9._~/-]*)
|
||||
_base_url_invalid=1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "${_base_url_invalid:-}" ]; then
|
||||
echo "18-resolve-base-url.envsh: error: BASE_URL='$BASE_URL' is not a plain path, falling back to /" >&2
|
||||
_base_url=/
|
||||
fi
|
||||
|
||||
if [ "$_base_url" != "/" ] && [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
|
||||
echo "18-resolve-base-url.envsh: info: serving the app under $_base_url"
|
||||
fi
|
||||
|
||||
BASE_URL="$_base_url"
|
||||
|
||||
# Regex-safe forms of the same value, for the rewrites in nginx.conf. `.` is a legal
|
||||
# character in a path and the validation above lets it through, but it is also the one
|
||||
# regex metacharacter that survives that filter: unescaped, a BASE_URL of `/it.tools/`
|
||||
# would strip the prefix from `/itXtools/...` too.
|
||||
BASE_URL_REGEX=$(printf '%s' "$_base_url" | sed 's/\./\\./g')
|
||||
# `/it-tools/` -> `/it-tools`, so nginx.conf can redirect the slash-less spelling to the
|
||||
# real one. Empty for a deployment at the root, where there is nothing to redirect.
|
||||
BASE_URL_NO_SLASH_REGEX="${BASE_URL_REGEX%/}"
|
||||
|
||||
export BASE_URL BASE_URL_REGEX BASE_URL_NO_SLASH_REGEX
|
||||
|
||||
unset _base_url _base_url_invalid
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
# vim:sw=4:ts=4:et
|
||||
#
|
||||
# 20-envsubst-on-templates.sh guards its output directory with `[ ! -w $dir ]`,
|
||||
# which only inspects permission bits. It therefore does not notice a read-only
|
||||
# *mount*: with `docker run --read-only` or a Kubernetes readOnlyRootFilesystem,
|
||||
# /etc/nginx/conf.d still looks writable, envsubst runs anyway, the redirect
|
||||
# fails with EROFS and `set -e` takes the container down. The image
|
||||
# crash-loops on every start.
|
||||
#
|
||||
# Probe the directory with a real write. If it fails, point the template
|
||||
# directory at a path that does not exist so 20-envsubst-on-templates.sh
|
||||
# returns early, and let nginx use the config rendered into the image at build
|
||||
# time instead. Sourced, not executed, so the export reaches later scripts.
|
||||
#
|
||||
# On a writable filesystem -- every deployment that works today -- the probe
|
||||
# succeeds and nothing is changed.
|
||||
|
||||
_envsubst_output_dir="${NGINX_ENVSUBST_OUTPUT_DIR:-/etc/nginx/conf.d}"
|
||||
_envsubst_probe="$_envsubst_output_dir/.readonly-probe.$$"
|
||||
|
||||
if [ -d "${NGINX_ENVSUBST_TEMPLATE_DIR:-/etc/nginx/templates}" ] \
|
||||
&& ! (touch "$_envsubst_probe" 2>/dev/null && rm -f "$_envsubst_probe" 2>/dev/null); then
|
||||
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
|
||||
echo "19-skip-envsubst-if-readonly.envsh: info: $_envsubst_output_dir is not writable, keeping the config baked into the image"
|
||||
fi
|
||||
# The baked config carries the image defaults, so anything that is only applied by
|
||||
# rendering the template is quietly lost. $PORT has always had this caveat; say so for
|
||||
# BASE_URL too, where the symptom (an app that loads from the wrong path) is a lot less
|
||||
# obvious than a port that did not move.
|
||||
if [ "${BASE_URL:-/}" != "/" ]; then
|
||||
echo "19-skip-envsubst-if-readonly.envsh: warning: BASE_URL=$BASE_URL cannot be applied on a read-only filesystem; mount a writable $_envsubst_output_dir (a tmpfs or an emptyDir will do)" >&2
|
||||
fi
|
||||
export NGINX_ENVSUBST_TEMPLATE_DIR=/nonexistent-read-only-filesystem
|
||||
fi
|
||||
|
||||
unset _envsubst_output_dir _envsubst_probe
|
||||
@@ -0,0 +1,55 @@
|
||||
#!/bin/sh
|
||||
# vim:sw=4:ts=4:et
|
||||
#
|
||||
# nginx.conf listens on both IPv4 and IPv6. On a host or container runtime with
|
||||
# IPv6 disabled, nginx refuses to start:
|
||||
#
|
||||
# socket() [::]:8080 failed (97: Address family not supported by protocol)
|
||||
#
|
||||
# Drop the IPv6 listen directives in that case. This runs after
|
||||
# 20-envsubst-on-templates.sh so it edits the rendered config, and it is a
|
||||
# no-op wherever IPv6 is available, which is the case the image already
|
||||
# handles today.
|
||||
|
||||
set -e
|
||||
|
||||
ME=$(basename "$0")
|
||||
|
||||
entrypoint_log() {
|
||||
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
|
||||
echo "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# Same check the stock 10-listen-on-ipv6-by-default.sh uses.
|
||||
if [ -f "/proc/net/if_inet6" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
output_dir="${NGINX_ENVSUBST_OUTPUT_DIR:-/etc/nginx/conf.d}"
|
||||
|
||||
[ -d "$output_dir" ] || exit 0
|
||||
|
||||
# `sed -i` rewrites through a temporary file in the directory, so the directory
|
||||
# has to be writable, not only the file. Probe it with a real write, the same
|
||||
# way 19-skip-envsubst-if-readonly.envsh does.
|
||||
probe="$output_dir/.ipv6-probe.$$"
|
||||
if ! (touch "$probe" 2>/dev/null && rm -f "$probe" 2>/dev/null); then
|
||||
entrypoint_log "$ME: info: ipv6 not available, but $output_dir is not writable (read-only file system?), leaving the config alone"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for conf in "$output_dir"/*.conf; do
|
||||
[ -f "$conf" ] || continue
|
||||
grep -q -E '^[[:space:]]*listen[[:space:]]+\[::\]' "$conf" || continue
|
||||
|
||||
# An individual file can still be mounted read-only inside a writable
|
||||
# directory, so a failed edit must not take the entrypoint down with it.
|
||||
if sed -i -E 's/^([[:space:]]*)(listen[[:space:]]+\[::\].*)$/\1# \2 # disabled by '"$ME"': no IPv6 on this host/' "$conf" 2>/dev/null; then
|
||||
entrypoint_log "$ME: info: ipv6 not available, disabled IPv6 listen in $conf"
|
||||
else
|
||||
entrypoint_log "$ME: info: ipv6 not available, but can not modify $conf, leaving it alone"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
||||
@@ -1,9 +1,14 @@
|
||||
services:
|
||||
it-tools:
|
||||
container_name: it-tools-subfolder
|
||||
image: ghcr.io/sharevb/it-tools:baseurl-it-tools
|
||||
image: ghcr.io/sharevb/it-tools:latest
|
||||
pull_policy: always
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
# The path the app is served under. This is all a subfolder deployment needs -- the
|
||||
# regular image works at any path, there is no subfolder-specific tag to pull and
|
||||
# nothing to rebuild.
|
||||
BASE_URL: /it-tools/
|
||||
nginx-reverse-proxy:
|
||||
image: nginx:alpine
|
||||
depends_on:
|
||||
@@ -11,4 +16,4 @@ services:
|
||||
volumes:
|
||||
- "./nginx.conf:/etc/nginx/conf.d/default.conf"
|
||||
ports:
|
||||
- 80:80
|
||||
- 80:80
|
||||
@@ -2,6 +2,9 @@ server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
# The trailing slash on proxy_pass strips /it-tools/ before the request reaches the
|
||||
# container. It works the other way round too -- `proxy_pass http://it-tools-subfolder:8080;`
|
||||
# forwards the prefix as-is -- because the app's own nginx.conf handles both.
|
||||
location /it-tools/ {
|
||||
proxy_pass http://it-tools-subfolder:8080/;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
services:
|
||||
it-tools:
|
||||
image: sharevb/it-tools:latest
|
||||
pull_policy: always
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- BASIC_AUTH=${BASIC_AUTH}
|
||||
volumes:
|
||||
- ./tools-settings.json:/usr/share/nginx/html/tools-settings.json
|
||||
ports:
|
||||
- 8080:8080
|
||||
docker-image-download-server:
|
||||
image: sharevb/docker-image-download-server:latest
|
||||
pull_policy: always
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- BASIC_AUTH=${BASIC_AUTH}
|
||||
ports:
|
||||
- 8001:3000
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
ws-tcp-udp-bridge:
|
||||
image: sharevb/ws-tcp-udp-bridge:latest
|
||||
pull_policy: always
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 8002:8080
|
||||
network-utils-ws:
|
||||
image: sharevb/network-utils-ws:latest
|
||||
pull_policy: always
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- BASIC_AUTH=${BASIC_AUTH}
|
||||
ports:
|
||||
- 8003:8000
|
||||
puppeteer-htmltopdf:
|
||||
image: sharevb/puppeteer-htmltopdf:latest
|
||||
pull_policy: always
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- BASIC_AUTH=${BASIC_AUTH}
|
||||
ports:
|
||||
- 8004:3000
|
||||
cors-anywhere:
|
||||
image: sharevb/cors-anywhere:latest
|
||||
pull_policy: always
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- CORSANYWHERE_BASIC_AUTH=${BASIC_AUTH}
|
||||
- CORSANYWHERE_ALLOWED_HTTP_METHODS=HEAD,GET,POST
|
||||
ports:
|
||||
- 8005:8080
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"dns-prop": {
|
||||
"url": "http://localhost:8003",
|
||||
"auth": "alice:b@b"
|
||||
},
|
||||
"dns-tester": {
|
||||
"url": "http://localhost:8003",
|
||||
"auth": "alice:b@b"
|
||||
},
|
||||
"docker-dl": {
|
||||
"url": "http://localhost:8001",
|
||||
"auth": "alice:b@b"
|
||||
},
|
||||
"html-to-pdf": {
|
||||
"url": "http://localhost:8004",
|
||||
"auth": "alice:b@b"
|
||||
},
|
||||
"https-tester": {
|
||||
"url": "http://localhost:8003",
|
||||
"auth": "alice:b@b"
|
||||
},
|
||||
"multi-links-dl": {
|
||||
"url": "http://localhost:8005",
|
||||
"auth": "alice:b@b"
|
||||
},
|
||||
"ping": {
|
||||
"url": "http://localhost:8003",
|
||||
"auth": "alice:b@b"
|
||||
},
|
||||
"short-urls-expander": {
|
||||
"cors-anywhere-url": "http://localhost:8005",
|
||||
"auth": "alice:b@b"
|
||||
},
|
||||
"tcp-udp-port-tester": {
|
||||
"ws": "ws://localhost:8002"
|
||||
}
|
||||
}
|
||||
+898
-1
File diff suppressed because it is too large.
Load diff
+901
-1
File diff suppressed because it is too large.
Load diff
+926
-1
File diff suppressed because it is too large.
Load diff
+926
-1
File diff suppressed because it is too large.
Load diff
+924
-21
File diff suppressed because it is too large.
Load diff
+918
-1
File diff suppressed because it is too large.
Load diff
+955
-38
File diff suppressed because it is too large.
Load diff
+921
-1
File diff suppressed because it is too large.
Load diff
+2274
-1367
File diff suppressed because it is too large.
Load diff
+5710
-4938
File diff suppressed because it is too large.
Load diff
+863
-1
File diff suppressed because it is too large.
Load diff
+914
-1
File diff suppressed because it is too large.
Load diff
+905
-1
File diff suppressed because it is too large.
Load diff
+914
-1
File diff suppressed because it is too large.
Load diff
+912
-1
File diff suppressed because it is too large.
Load diff
+924
-1
File diff suppressed because it is too large.
Load diff
+914
-1
File diff suppressed because it is too large.
Load diff
+910
-1
File diff suppressed because it is too large.
Load diff
+914
-1
File diff suppressed because it is too large.
Load diff
+9939
File diff suppressed because it is too large.
Load diff
+4264
-3388
File diff suppressed because it is too large.
Load diff
+55
-5
@@ -10,17 +10,67 @@ server {
|
||||
#add_header Referrer-Policy strict-origin-when-cross-origin;
|
||||
#add_header X-Permitted-Cross-Domain-Policies none;
|
||||
#add_header Cross-Origin-Resource-Policy same-site;
|
||||
#add_header Cross-Origin-Opener-Policy same-origin;
|
||||
#add_header Cross-Origin-Embedder-Policy require-corp;
|
||||
add_header Cross-Origin-Opener-Policy same-origin;
|
||||
add_header Cross-Origin-Embedder-Policy require-corp;
|
||||
#add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' http: https: blob:; style-src 'self' 'unsafe-inline' https: http:; img-src 'self' data: blob: https: http:; connect-src data: blob: https: http:; font-src 'self' https: http:; object-src 'none'; base-uri 'self'; form-action 'self';";
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
types {
|
||||
application/javascript js mjs;
|
||||
# mime.types already maps js, remapping it here only emits a
|
||||
# "duplicate extension" warning on every startup.
|
||||
application/javascript mjs;
|
||||
}
|
||||
|
||||
# `/it-tools` is the same place as `/it-tools/`, but only the second one gives the
|
||||
# browser the right directory to resolve the app's relative URLs against, so send the
|
||||
# first one there. Renders to `^$` -- which no request URI can match -- when the app is
|
||||
# served from the root. Relative Location headers, because $scheme is whatever the
|
||||
# reverse proxy used to reach the container, not what the browser used.
|
||||
absolute_redirect off;
|
||||
rewrite ^${BASE_URL_NO_SLASH_REGEX}$ ${BASE_URL} permanent;
|
||||
|
||||
# Serving the app from a subpath (BASE_URL, normalised by
|
||||
# docker-entrypoint.d/18-resolve-base-url.envsh, `/` by default).
|
||||
#
|
||||
# The build is path-agnostic: every asset is referenced relatively, and the one
|
||||
# absolute anchor is a `<base href="/">` in index.html that the app itself reads its
|
||||
# base from (src/utils/base-url.ts). Rewriting that single tag on the way out is
|
||||
# therefore enough to move the whole app to another path -- no rebuild, no
|
||||
# subpath-specific image.
|
||||
#
|
||||
# sub_filter drops Last-Modified/ETag from every response it touches, and text/html is
|
||||
# always in scope (sub_filter_types can add types, not exclude HTML). So: index.html,
|
||||
# which an SPA must not cache anyway and which the service worker precaches regardless,
|
||||
# and the one other HTML document in the build -- the visual-subnet-calculator's iframe,
|
||||
# public/visualsubnetcalc/calc.html -- which loses conditional revalidation and is
|
||||
# refetched in full when that tool is opened.
|
||||
sub_filter '<base href="/">' '<base href="${BASE_URL}">';
|
||||
sub_filter_once on;
|
||||
|
||||
# Hashed build output, with or without the deployment prefix in front of it: a reverse
|
||||
# proxy may pass `/it-tools/assets/...` through as-is or strip the prefix first, and
|
||||
# both have to land on the same file. Without this, a missing chunk falls through to
|
||||
# index.html below and is served as text/html with a 200, which the browser rejects
|
||||
# with an opaque MIME error instead of a plain 404.
|
||||
location ~ ^/(?:.*/)?assets/(?<asset>.+)$ {
|
||||
# Serve gzip sidecars when supported, including requests from reverse proxies.
|
||||
gzip_static on;
|
||||
gzip_proxied any;
|
||||
gzip_vary on;
|
||||
try_files /assets/$asset =404;
|
||||
}
|
||||
|
||||
location / {
|
||||
rewrite ^/it-tools/(.*) /$1 break;
|
||||
try_files $uri $uri/ /index.html;
|
||||
# Same story for everything else the app fetches by path (the JSON config files,
|
||||
# the WASM helpers in public/): drop the deployment prefix when the proxy forwarded
|
||||
# it instead of stripping it. Renders to `^/(.*)$` -- a no-op -- for the default
|
||||
# BASE_URL of `/`.
|
||||
rewrite ^${BASE_URL_REGEX}(.*)$ /$1 break;
|
||||
# No `$uri/`: nothing in the build is a directory with an index in it, so the only
|
||||
# thing matching one ever produced was nginx's own "add the trailing slash"
|
||||
# redirect -- computed from the URI *after* the rewrite above, so under a subpath
|
||||
# `/it-tools/figlet-fonts` bounced the browser out of the app to `/figlet-fonts/`
|
||||
# (and then to a 403). Unknown paths belong to the SPA, which has a 404 page.
|
||||
try_files $uri /index.html;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { defineConfig } from 'oxfmt';
|
||||
|
||||
export default defineConfig({
|
||||
printWidth: 120,
|
||||
tabWidth: 2,
|
||||
useTabs: false,
|
||||
semi: true,
|
||||
singleQuote: true,
|
||||
trailingComma: 'all',
|
||||
arrowParens: 'always',
|
||||
endOfLine: 'lf',
|
||||
ignorePatterns: [
|
||||
'src/libs/**',
|
||||
'dist/**',
|
||||
'coverage/**',
|
||||
'auto-imports.d.ts',
|
||||
'components.d.ts',
|
||||
'pnpm-lock.yaml',
|
||||
],
|
||||
});
|
||||
@@ -0,0 +1,87 @@
|
||||
import { defineConfig } from 'oxlint';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: ['eslint', 'typescript', 'oxc', 'unicorn', 'import', 'promise', 'vue', 'vitest'],
|
||||
categories: {
|
||||
correctness: 'error',
|
||||
},
|
||||
// Type-aware rules run through oxlint-tsgolint, which ships its own checker
|
||||
// binary, so this does not depend on the project's TypeScript version.
|
||||
// Note it only analyses .ts files -- .vue script blocks are covered by
|
||||
// `pnpm typecheck` (vue-tsc) instead.
|
||||
options: {
|
||||
typeAware: true,
|
||||
},
|
||||
env: {
|
||||
browser: true,
|
||||
es2026: true,
|
||||
},
|
||||
globals: {
|
||||
process: 'readonly',
|
||||
},
|
||||
ignorePatterns: [
|
||||
'src/libs/**',
|
||||
'dist/**',
|
||||
'coverage/**',
|
||||
'auto-imports.d.ts',
|
||||
'components.d.ts',
|
||||
],
|
||||
rules: {
|
||||
'eslint/curly': ['error', 'all'],
|
||||
'typescript/no-use-before-define': [
|
||||
'error',
|
||||
{ allowNamedExports: true, functions: false },
|
||||
],
|
||||
'eslint/no-restricted-imports': [
|
||||
'error',
|
||||
{
|
||||
paths: [
|
||||
{
|
||||
name: '@vueuse/core',
|
||||
importNames: ['useClipboard'],
|
||||
message: 'Please use local useCopy from src/composable/copy.ts instead of useClipboard.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
'no-undef': 'off',
|
||||
'eslint/no-unused-vars': [
|
||||
'error',
|
||||
{ caughtErrors: 'none', varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
|
||||
],
|
||||
'eslint/no-useless-escape': 'off',
|
||||
|
||||
// Staged as warnings while the existing findings are worked through, so
|
||||
// they surface without failing the build. Promote to "error" per rule as
|
||||
// each one reaches zero.
|
||||
'typescript/await-thenable': 'warn',
|
||||
'typescript/no-base-to-string': 'warn',
|
||||
'typescript/no-duplicate-type-constituents': 'warn',
|
||||
'typescript/no-floating-promises': 'warn',
|
||||
'typescript/no-for-in-array': 'warn',
|
||||
'typescript/no-misused-spread': 'warn',
|
||||
'typescript/no-redundant-type-constituents': 'warn',
|
||||
'typescript/no-useless-default-assignment': 'warn',
|
||||
'typescript/restrict-template-expressions': 'warn',
|
||||
'typescript/unbound-method': 'warn',
|
||||
|
||||
'import/default': 'off',
|
||||
'vue/no-dupe-keys': 'off',
|
||||
'vitest/valid-expect': 'off',
|
||||
'vitest/expect-expect': 'off',
|
||||
'vitest/require-to-throw-message': 'off',
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['**/*.test.ts', '**/*.spec.ts', '**/*.e2e.spec.ts'],
|
||||
env: { vitest: true },
|
||||
},
|
||||
{
|
||||
files: ['**/calendar-converter/calendar-converter.service.ts'],
|
||||
rules: {
|
||||
'eslint/no-unused-vars': 'off',
|
||||
'oxc/erasing-op': 'off',
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
+185
-166
@@ -1,34 +1,31 @@
|
||||
{
|
||||
"name": "it-tools",
|
||||
"type": "module",
|
||||
"version": "2026.7.11",
|
||||
"packageManager": "pnpm@11.11.0+sha512.4463f65fd80ed80d69bc1d4bf163ee94f605c7380fc318bb5b2ebe15f8cd12d49c51a4d59e951b401e764d3b6ca751cbf51bc50ed7001a6bcb4935e684c34882",
|
||||
"version": "2026.11.22",
|
||||
"description": "Collection of handy online tools for developers, with great UX. ",
|
||||
"author": "Corentin Th <corentin.thomasset74+it-tools@gmail.com> (https://corentin.tech)",
|
||||
"keywords": [
|
||||
"converter",
|
||||
"developer-productivity",
|
||||
"developer-tools",
|
||||
"frontend",
|
||||
"productivity",
|
||||
"tool",
|
||||
"tools",
|
||||
"vuejs",
|
||||
"website"
|
||||
],
|
||||
"license": "GNU GPLv3",
|
||||
"author": "Corentin Th <corentin.thomasset74+it-tools@gmail.com> (https://corentin.tech)",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sharevb/it-tools"
|
||||
},
|
||||
"keywords": [
|
||||
"productivity",
|
||||
"converter",
|
||||
"website",
|
||||
"vuejs",
|
||||
"tools",
|
||||
"frontend",
|
||||
"tool",
|
||||
"developer-tools",
|
||||
"developer-productivity"
|
||||
],
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vue-tsc --noEmit && . ./set_node_mem.sh && vite build",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview --port 5050",
|
||||
"test": "TZ=UTC npm run test:unit",
|
||||
"test:unit": "TZ=UTC . ./set_node_mem.sh && vitest --environment jsdom",
|
||||
"test:e2e": "TZ=UTC . ./set_node_mem.sh && playwright test",
|
||||
"test:e2e:dev": "TZ=UTC BASE_URL=http://localhost:5173 NO_WEB_SERVER=true playwright test",
|
||||
"test:unit": "vitest",
|
||||
"test:e2e": "playwright test",
|
||||
"coverage": "vitest run --coverage",
|
||||
"typecheck": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
|
||||
"lint": "oxlint src",
|
||||
@@ -40,6 +37,7 @@
|
||||
"release": "node ./scripts/release.mjs",
|
||||
"script:extract:desc": "node ./scripts/extract-tools-desc.mjs",
|
||||
"script:extract:strings": "node ./scripts/extract-tools-strings.mjs",
|
||||
"script:update:git-templates": "node ./scripts/update-git-templates.mjs",
|
||||
"script:translate-missing": "node ./scripts/translate-missings.mjs -e ./locales/en.yml -t ./locales/*.yml",
|
||||
"vue-i18n-extract": "vue-i18n-extract report --vueFiles 'src/**/*.?(ts|vue)' --languageFiles 'locales/*.yml'",
|
||||
"precommit": "pnpm install --ignore-scripts && pnpm lint:fix && pnpm typecheck"
|
||||
@@ -66,60 +64,66 @@
|
||||
"@colordx/core": "^5.5.0",
|
||||
"@date-fns/utc": "^2.1.1",
|
||||
"@dice-roller/rpg-dice-roller": "^5.5.1",
|
||||
"@faker-js/faker": "^10.2.0",
|
||||
"@faker-js/faker": "^10.5.0",
|
||||
"@ffmpeg/core": "0.12.10",
|
||||
"@ffmpeg/ffmpeg": "^0.12.15",
|
||||
"@ffmpeg/util": "^0.12.2",
|
||||
"@finegym/fitness-calc": "^1.0.1",
|
||||
"@fortawesome/fontawesome-svg-core": "^6.7.2",
|
||||
"@fortawesome/free-solid-svg-icons": "^6.7.2",
|
||||
"@fortawesome/vue-fontawesome": "^3.0.8",
|
||||
"@fontsource/open-sans": "^5.3.0",
|
||||
"@fontsource/varela-round": "^5.3.0",
|
||||
"@fortawesome/fontawesome-svg-core": "^7.3.0",
|
||||
"@fortawesome/free-solid-svg-icons": "^7.3.0",
|
||||
"@fortawesome/vue-fontawesome": "^3.3.1",
|
||||
"@github/paste-markdown": "^1.5.3",
|
||||
"@guolao/vue-monaco-editor": "^1.5.5",
|
||||
"@guolao/vue-monaco-editor": "^1.6.0",
|
||||
"@guyplusplus/turndown-plugin-gfm": "^1.0.7",
|
||||
"@huggingface/transformers": "3.7.2",
|
||||
"@iplookup/country-extra": "^1.0.20251209",
|
||||
"@huggingface/transformers": "3.7.6",
|
||||
"@iplookup/country-extra": "^1.0.20260711",
|
||||
"@it-tools/bip39": "^0.0.4",
|
||||
"@it-tools/oggen": "^1.3.0",
|
||||
"@jsonquerylang/jsonquery": "^5.1.1",
|
||||
"@kenjiuno/decompressrtf": "^0.1.4",
|
||||
"@kenjiuno/msgreader": "^1.27.0",
|
||||
"@kenjiuno/msgreader": "^1.28.0",
|
||||
"@langfreak/convert-layout": "^0.11.2",
|
||||
"@lezer/highlight": "^1.2.3",
|
||||
"@mdit/plugin-align": "^0.16.0",
|
||||
"@noble/ciphers": "^1.2.1",
|
||||
"@noble/ciphers": "^1.3.0",
|
||||
"@plausible-analytics/tracker": "^0.4.6",
|
||||
"@regexper/render": "^1.0.0",
|
||||
"@resvg/resvg-wasm": "^2.6.2",
|
||||
"@sindresorhus/slugify": "^3.0.0",
|
||||
"@skeepit/unicode-to-gsm7": "^1.0.0",
|
||||
"@tabler/icons-vue": "^3.30.0",
|
||||
"@tiptap/core": "^3.22.5",
|
||||
"@tiptap/extension-color": "^3.22.5",
|
||||
"@tiptap/extension-gapcursor": "^3.22.5",
|
||||
"@tiptap/extension-highlight": "^3.22.5",
|
||||
"@tiptap/extension-table": "^3.22.5",
|
||||
"@tiptap/extension-text-align": "^3.22.5",
|
||||
"@tiptap/extension-text-style": "^3.22.5",
|
||||
"@tiptap/extensions": "^3.22.5",
|
||||
"@tiptap/pm": "^3.22.5",
|
||||
"@tiptap/starter-kit": "^3.22.5",
|
||||
"@tiptap/vue-3": "^3.22.5",
|
||||
"@toon-format/toon": "^2.1.0",
|
||||
"@tabler/icons-vue": "^3.44.0",
|
||||
"@tesseract.js-data/chi_sim": "^1.0.0",
|
||||
"@tesseract.js-data/eng": "^1.0.0",
|
||||
"@tiptap/core": "^3.31.3",
|
||||
"@tiptap/extension-color": "^3.31.3",
|
||||
"@tiptap/extension-gapcursor": "^3.31.3",
|
||||
"@tiptap/extension-highlight": "^3.31.3",
|
||||
"@tiptap/extension-table": "^3.31.3",
|
||||
"@tiptap/extension-text-align": "^3.31.3",
|
||||
"@tiptap/extension-text-style": "^3.31.3",
|
||||
"@tiptap/extensions": "^3.31.3",
|
||||
"@tiptap/pm": "^3.31.3",
|
||||
"@tiptap/starter-kit": "^3.31.3",
|
||||
"@tiptap/vue-3": "^3.31.3",
|
||||
"@toon-format/toon": "^4.1.1",
|
||||
"@types/haversine": "^1.1.8",
|
||||
"@types/html-to-text": "^9.0.4",
|
||||
"@types/swagger-ui-dist": "^3.30.6",
|
||||
"@unicode/unicode-15.1.0": "^1.6.16",
|
||||
"@unicode/unicode-15.1.0": "^1.6.17",
|
||||
"@vicons/material": "^0.12.0",
|
||||
"@vicons/tabler": "^0.12.0",
|
||||
"@vueuse/core": "^10.11.1",
|
||||
"@vueuse/head": "^1.3.1",
|
||||
"@vueuse/integrations": "^14.2.0",
|
||||
"@vueuse/router": "^10.0.0",
|
||||
"@xmldom/xmldom": "^0.8.13",
|
||||
"@vueuse/integrations": "^14.3.0",
|
||||
"@vueuse/router": "^10.11.1",
|
||||
"@xmldom/xmldom": "^0.8.15",
|
||||
"@xterm/xterm": "^5.5.0",
|
||||
"@younestouati/playing-cards-standard-deck": "^6.0.1",
|
||||
"@zxcvbn-ts/core": "^3.0.4",
|
||||
"@zxcvbn-ts/language-common": "^3.0.4",
|
||||
"@zxcvbn-ts/language-en": "^3.0.2",
|
||||
"@zxing/library": "^0.21.3",
|
||||
"@zxing/library": "^0.23.0",
|
||||
"a11y-color-contrast": "^0.2.0",
|
||||
"abort-signal-polyfill": "^1.0.0",
|
||||
"aircodes": "^1.3.16",
|
||||
@@ -133,41 +137,41 @@
|
||||
"bech32": "^2.0.0",
|
||||
"big.js": "^7.0.1",
|
||||
"braces": "^3.0.3",
|
||||
"bwip-js": "^4.8.0",
|
||||
"bwip-js": "^4.11.2",
|
||||
"byte-data": "^19.0.1",
|
||||
"change-case": "^5.4.4",
|
||||
"chardet": "^2.1.1",
|
||||
"chardet": "^2.2.0",
|
||||
"chart.js": "^4.5.1",
|
||||
"chartjs-plugin-zoom": "^2.2.0",
|
||||
"chatgpt-prompt-splitter": "^1.0.5",
|
||||
"chinesegen": "^0.3.3",
|
||||
"cidr-tools": "^11.0.3",
|
||||
"cidr-tools": "^13.0.4",
|
||||
"citation-formatter": "^1.0.1",
|
||||
"codemirror": "^6.0.2",
|
||||
"colord": "^2.9.3",
|
||||
"composerize": "^1.7.5",
|
||||
"colord": "^2.10.0",
|
||||
"composerize": "^1.7.6",
|
||||
"composeverter": "^1.7.5",
|
||||
"convert": "^6.0.0",
|
||||
"countries-and-timezones": "^3.8.0",
|
||||
"convert": "^7.0.2",
|
||||
"countries-and-timezones": "^3.9.0",
|
||||
"countries-db": "^1.2.0",
|
||||
"country-code-lookup": "^0.1.3",
|
||||
"country-code-lookup": "^0.1.5",
|
||||
"crc": "^4.3.2",
|
||||
"creditcard": "^0.1.3",
|
||||
"creditcard-generator": "^0.0.7",
|
||||
"cron-parser": "4.9.0",
|
||||
"cron-parser": "5.10.0",
|
||||
"cron-validator": "^1.4.0",
|
||||
"cronstrue": "^3.1.0",
|
||||
"cronstrue": "^3.24.0",
|
||||
"cropperjs": "^1.6.3",
|
||||
"cross-spawn": "^7.0.6",
|
||||
"crypto-js": "^4.2.0",
|
||||
"crypto-es": "^3.1.3",
|
||||
"csstoxpath": "^2.0.0",
|
||||
"curlconverter": "^4.12.0",
|
||||
"currency-codes-ts": "^3.0.0",
|
||||
"currency-exchanger-js": "^1.0.4",
|
||||
"damerau-levenshtein": "^1.0.8",
|
||||
"data-guardian": "^1.1.3",
|
||||
"date-fns": "^4.1.0",
|
||||
"data-guardian": "^1.1.4",
|
||||
"date-fns": "^4.4.0",
|
||||
"date-fns-tz": "^3.2.0",
|
||||
"date-holidays": "^3.27.0",
|
||||
"date-holidays": "^3.34.1",
|
||||
"decimal.js": "^10.6.0",
|
||||
"decomposerize": "^1.4.4",
|
||||
"detect-csv": "^1.1.0",
|
||||
@@ -181,30 +185,31 @@
|
||||
"dmarc-report-parser": "^0.1.5",
|
||||
"dns-query": "^0.11.2",
|
||||
"docker2kube": "^0.0.14",
|
||||
"dom-to-image-more": "^3.7.2",
|
||||
"dompurify": "^3.4.2",
|
||||
"dom-to-image-more": "^3.10.0",
|
||||
"dompurify": "^3.4.16",
|
||||
"duration-fns": "^3.0.2",
|
||||
"echarts": "^6.1.0",
|
||||
"email-bounce-parser-browser": "^1.1.0",
|
||||
"email-normalizer": "^1.0.0",
|
||||
"emojilib": "^4.0.2",
|
||||
"emojilib": "^4.0.3",
|
||||
"epubjs": "^0.3.93",
|
||||
"es-toolkit": "^1.49.0",
|
||||
"esm-potrace-wasm": "^0.4.4",
|
||||
"ethers": "^6.16.0",
|
||||
"ethers": "^6.17.0",
|
||||
"event-cron-parser": "^1.0.37",
|
||||
"exif-be-gone": "^1.5.1",
|
||||
"exifreader": "^4.33.1",
|
||||
"exifreader": "^4.46.0",
|
||||
"fanger": "0.3.1",
|
||||
"fast-json-patch": "^3.1.1",
|
||||
"fast-xml-parser": "^5.7.2",
|
||||
"fast-xml-parser": "^5.11.1",
|
||||
"fast_array_intersect": "^1.1.0",
|
||||
"fflate": "^0.8.2",
|
||||
"figlet": "^1.9.4",
|
||||
"fflate": "^0.8.3",
|
||||
"figlet": "^1.11.0",
|
||||
"figue": "^1.2.0",
|
||||
"file-type": "^21.3.4",
|
||||
"file-type": "^22.0.1",
|
||||
"flatten-anything": "^4.0.2",
|
||||
"flexsearch": "^0.8.212",
|
||||
"fuse.js": "^7.1.0",
|
||||
"fuse.js": "^7.4.2",
|
||||
"gcoord": "^1.0.7",
|
||||
"generate-schema": "^2.6.0",
|
||||
"get-timezone-offset": "^1.0.5",
|
||||
@@ -215,113 +220,114 @@
|
||||
"heic-convert": "^2.1.0",
|
||||
"hex-array": "^1.0.0",
|
||||
"highlight.js": "^11.11.1",
|
||||
"html-to-text": "^9.0.5",
|
||||
"htmlfy": "^1.0.1",
|
||||
"htmlparser2": "^10.0.0",
|
||||
"hyparquet": "^1.23.3",
|
||||
"html-to-text": "^10.0.0",
|
||||
"htmlfy": "^1.0.2",
|
||||
"htmlparser2": "^10.1.0",
|
||||
"hyparquet": "^1.26.2",
|
||||
"hyparquet-compressors": "^1.1.1",
|
||||
"ibantools": "^4.5.1",
|
||||
"ical-generator": "^10.0.0",
|
||||
"ibantools": "^4.5.4",
|
||||
"ical-generator": "^11.0.0",
|
||||
"ical.js": "^2.2.1",
|
||||
"iconv-lite": "^0.7.2",
|
||||
"idb-keyval": "^6.2.2",
|
||||
"iconv-lite": "^0.7.3",
|
||||
"idb-keyval": "^6.3.0",
|
||||
"image-compare-viewer": "^1.6.2",
|
||||
"image-in-browser": "^3.3.0",
|
||||
"image-in-browser": "^3.5.3",
|
||||
"image-to-ascii-art": "^0.0.4",
|
||||
"ip-address": "^10.1.0",
|
||||
"ip-bigint": "^8.2.2",
|
||||
"ip-address": "^10.7.2",
|
||||
"ip-bigint": "^9.0.6",
|
||||
"ip-cidr": "^4.0.2",
|
||||
"ip-matching": "^2.1.2",
|
||||
"ip-regex": "^5.0.0",
|
||||
"is-cidr": "^6.0.1",
|
||||
"is-cidr": "^7.0.0",
|
||||
"is-ip": "^5.0.1",
|
||||
"isbn3": "^2.0.2",
|
||||
"iso-639-1": "^3.1.5",
|
||||
"isbn3": "^2.0.9",
|
||||
"iso-639-1": "^3.1.6",
|
||||
"jasypt": "^1.0.7",
|
||||
"javascript-obfuscator": "^5.4.6",
|
||||
"javascript-obfuscator": "^5.4.7",
|
||||
"javastack.js": "^1.0.3",
|
||||
"jks-js": "^1.1.4",
|
||||
"jks-js": "^1.1.7",
|
||||
"jose": "5.10.0",
|
||||
"jpeg-quality-estimator": "^1.0.1",
|
||||
"jq-wasm": "^1.0.1",
|
||||
"js-base64": "^3.7.8",
|
||||
"js-beautify": "^1.15.4",
|
||||
"js-base64": "^3.9.4",
|
||||
"js-beautify": "^2.0.3",
|
||||
"js-tiktoken": "^1.0.21",
|
||||
"jsbarcode": "^3.12.1",
|
||||
"jsbarcode": "^3.12.3",
|
||||
"json-analyzer": "^1.2.2",
|
||||
"json-editor-vue": "^0.18.1",
|
||||
"json-editor-vue": "^0.19.2",
|
||||
"json-to-ts": "^2.1.0",
|
||||
"json5": "^2.2.3",
|
||||
"jsonar-mod": "^1.9.0",
|
||||
"jsonlint-mod": "^1.7.6",
|
||||
"jsonpath": "^1.3.0",
|
||||
"jsonrepair": "^3.13.1",
|
||||
"jsonrepair": "^3.15.0",
|
||||
"jsonschema": "^1.5.0",
|
||||
"jsonschema-protobuf": "^1.0.2",
|
||||
"jsstack.js": "^2.0.0",
|
||||
"jsvat-next": "^3.0.4",
|
||||
"jszip": "^3.10.1",
|
||||
"jwt-decode": "^4.0.0",
|
||||
"katex": "^0.17.0",
|
||||
"korean-unpacker": "^1.0.3",
|
||||
"langs": "^2.0.0",
|
||||
"leaflet": "^1.9.4",
|
||||
"libmime": "^5.3.8",
|
||||
"libphonenumber-js": "^1.12.33",
|
||||
"libmime": "^5.4.1",
|
||||
"libphonenumber-js": "^1.13.8",
|
||||
"lodash": "^4.18.1",
|
||||
"long": "^5.3.2",
|
||||
"lorem-ipsum-japanese": "^1.0.1",
|
||||
"luhn-js": "^1.1.2",
|
||||
"luxon": "^3.7.1",
|
||||
"markdown-docx": "^1.6.0",
|
||||
"markdown-it": "^14.1.1",
|
||||
"luxon": "^3.7.2",
|
||||
"markdown-docx": "^1.7.0",
|
||||
"markdown-it": "^14.3.0",
|
||||
"markdown-it-mark": "^4.0.0",
|
||||
"markdown-it-sanitizer": "^0.4.3",
|
||||
"markdown-it-sub": "^2.0.0",
|
||||
"markdown-it-sup": "^2.0.0",
|
||||
"markdown-table-prettify": "^4.0.0",
|
||||
"markdown-table-prettify": "^4.1.0",
|
||||
"marked": "^10.0.0",
|
||||
"mathjs": "^15.2.0",
|
||||
"md-editor-v3": "^4.21.3",
|
||||
"md-editor-v3": "^7.0.0",
|
||||
"mdt2json": "^1.1.0",
|
||||
"memorystream": "^0.3.1",
|
||||
"merge-anything": "^6.0.6",
|
||||
"mermaid": "^11.12.2",
|
||||
"mermaid": "^12.0.0",
|
||||
"mime-types": "^3.0.2",
|
||||
"mitex-wasm": "^0.2.5",
|
||||
"monaco-editor": "^0.55.1",
|
||||
"morsee": "^1.0.10",
|
||||
"msgpackr": "^1.11.8",
|
||||
"naive-ui": "^2.43.2",
|
||||
"nanoid": "^5.1.6",
|
||||
"msgpackr": "^2.0.4",
|
||||
"naive-ui": "^2.44.1",
|
||||
"nanoid": "^6.0.0",
|
||||
"nanoid-dictionary": "^5.0.0",
|
||||
"nestify-anything": "^4.0.1",
|
||||
"netmask": "^2.0.2",
|
||||
"netmask": "^2.1.1",
|
||||
"netstack.js": "^2.1.4",
|
||||
"nginx-config-formatter": "^1.4.5",
|
||||
"niceware": "^4.0.0",
|
||||
"node-emv": "^1.0.23",
|
||||
"node-forge": "^1.4.0",
|
||||
"openai-chat-tokens": "^0.2.8",
|
||||
"openpgp": "^6.3.0",
|
||||
"openpgp": "^6.3.1",
|
||||
"otpauth-migration": "^1.0.0",
|
||||
"oui-data": "^1.1.571",
|
||||
"pako": "^3.0.0",
|
||||
"parse-duration": "^2.1.6",
|
||||
"parse-torrent": "^11.0.19",
|
||||
"paseto-ts": "^2.0.5",
|
||||
"path2d-polyfill": "^3.1.3",
|
||||
"pako": "^3.0.1",
|
||||
"parse-duration": "^2.1.8",
|
||||
"parse-torrent": "^11.0.21",
|
||||
"paseto-ts": "^2.0.6",
|
||||
"path2d-polyfill": "^3.2.2",
|
||||
"pdf-signature-reader": "^1.4.3",
|
||||
"pdfjs-dist": "^4.10.38",
|
||||
"picomatch": "^4.0.5",
|
||||
"pinia": "^2.0.34",
|
||||
"plausible-tracker": "^0.3.9",
|
||||
"pinia": "^3.0.4",
|
||||
"podletjs": "^1.0.2",
|
||||
"port-numbers": "^8.0.28",
|
||||
"postal-mime": "^2.7.1",
|
||||
"port-numbers": "^8.0.32",
|
||||
"postal-mime": "^2.7.5",
|
||||
"potrace": "^2.1.8",
|
||||
"pp-qr-code": "^0.6.4",
|
||||
"prettier": "^3.9.9",
|
||||
"pretty-ms": "^9.3.0",
|
||||
"proj4": "^2.20.2",
|
||||
"proj4": "^2.20.9",
|
||||
"proj4-list": "^1.0.4",
|
||||
"properties": "^1.2.1",
|
||||
"punycode": "^2.3.1",
|
||||
@@ -331,140 +337,138 @@
|
||||
"qrcode-parser": "^2.1.3",
|
||||
"qrcode-terminal-nooctal": "^0.12.1",
|
||||
"qrcode-vue3": "^1.7.1",
|
||||
"quicktype-core": "^23.2.6",
|
||||
"quicktype-core": "^26.0.0",
|
||||
"randexp": "^0.5.3",
|
||||
"regex": "^6.1.0",
|
||||
"rekcod": "^3.0.0",
|
||||
"remove-markdown": "^0.6.3",
|
||||
"resistor-data": "^1.1.1",
|
||||
"remove-markdown": "^0.6.4",
|
||||
"resistor-data": "^2.0.0",
|
||||
"riimut": "^0.9.1",
|
||||
"roboto-base64": "^0.1.2",
|
||||
"rtf-stream-parser": "^3.8.1",
|
||||
"run-pace": "^2.2.0",
|
||||
"run-pace": "^2.2.1",
|
||||
"safe-license-list": "^0.1.2",
|
||||
"sandybox": "^1.1.2",
|
||||
"sanitize-html": "^2.17.0",
|
||||
"sanitize-html": "^2.17.7",
|
||||
"screenfull": "^5.2.0",
|
||||
"shamirs-secret-sharing": "^2.0.1",
|
||||
"shiki": "1.29.2",
|
||||
"silly-password-generator": "^1.0.29",
|
||||
"slashes": "^3.0.12",
|
||||
"smol-toml": "^1.6.1",
|
||||
"smol-toml": "^1.9.0",
|
||||
"sms-segments-calculator": "^1.2.0",
|
||||
"spdx-satisfies": "^6.0.0",
|
||||
"sponge-case": "^2.0.3",
|
||||
"sql-formatter": "^15.6.12",
|
||||
"sql-formatter": "^15.8.2",
|
||||
"sshpk": "^1.18.0",
|
||||
"staveless-futhark": "^0.6.1",
|
||||
"stopword": "^3.1.5",
|
||||
"stringify-object": "^6.0.0",
|
||||
"svg2png-wasm": "^1.4.1",
|
||||
"svgo": "^3.3.3",
|
||||
"swagger-ui-dist": "^5.27.0",
|
||||
"stringify-object": "^7.0.0",
|
||||
"svgo": "^3.3.5",
|
||||
"swagger-ui-dist": "^5.32.8",
|
||||
"swap-case": "^3.0.3",
|
||||
"tesseract.js": "^5.1.1",
|
||||
"text-encoding-utf-8": "^1.0.2",
|
||||
"tesseract.js": "^7.0.0",
|
||||
"tesseract.js-core": "7.0.0",
|
||||
"tick-time": "^1.0.1",
|
||||
"tidy-url": "^1.18.3",
|
||||
"title-case": "^4.3.2",
|
||||
"to-double-quotes": "^4.0.0",
|
||||
"to-single-quotes": "^4.0.0",
|
||||
"turndown": "^7.2.4",
|
||||
"ua-parser-js": "^2.0.4",
|
||||
"ua-parser-js": "^2.0.10",
|
||||
"ulid": "^3.0.2",
|
||||
"unicode-emoji-json": "^0.8.0",
|
||||
"unicode-emoji-json": "^0.9.0",
|
||||
"unique-random": "^4.0.0",
|
||||
"units-converter": "^1.0.3",
|
||||
"unixcrypt-browser": "^2.0.4",
|
||||
"unpdf": "^1.4.0",
|
||||
"unpdf": "^1.8.0",
|
||||
"unplugin-auto-import": "^21.0.0",
|
||||
"utf8": "^3.0.0",
|
||||
"uuid": "^14.0.0",
|
||||
"vanilla-jsoneditor": "^3.11.0",
|
||||
"uuid": "^14.0.1",
|
||||
"vanilla-jsoneditor": "^3.13.0",
|
||||
"vite-plugin-sitemap": "^0.8.2",
|
||||
"vue": "^3.5.39",
|
||||
"vue-color-wheel": "^0.1.1",
|
||||
"vue-i18n": "^11.4.0",
|
||||
"vue-i18n": "^11.4.6",
|
||||
"vue-loading-overlay": "^6.0.6",
|
||||
"vue-markdown-render": "^2.3.0",
|
||||
"vue-mathjax-next": "^0.0.6",
|
||||
"vue-router": "^4.1.6",
|
||||
"vue-markdown-render": "^2.3.1",
|
||||
"vue-router": "^5.1.0",
|
||||
"vue-shadow-dom": "^4.2.0",
|
||||
"vue-tsc": "^3.3.6",
|
||||
"vue-tsc": "^3.3.10",
|
||||
"vue3-flip-countdown": "^0.1.6",
|
||||
"vue3-katex": "^0.8.1",
|
||||
"vuedraggable": "^4.1.0",
|
||||
"vuex": "^4.1.0",
|
||||
"w-websocket-client": "^1.0.29",
|
||||
"webcrack": "^2.15.0",
|
||||
"webcrack": "^2.16.0",
|
||||
"webcrypto-liner-shim": "^1.4.8",
|
||||
"webp-converter-browser": "^1.0.4",
|
||||
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
|
||||
"xml-formatter": "^3.6.7",
|
||||
"xml-formatter": "^3.7.0",
|
||||
"xml-js": "^1.6.11",
|
||||
"xpath": "^0.0.34",
|
||||
"xpath-to-css": "^1.2.0",
|
||||
"xslt-processor": "^3.4.0",
|
||||
"yaml": "^2.8.4"
|
||||
"yaml": "^2.9.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify-json/mdi": "^1.2.3",
|
||||
"@iconify-json/tabler": "^1.2.35",
|
||||
"@intlify/unplugin-vue-i18n": "^11.2.4",
|
||||
"@playwright/test": "^1.59.1",
|
||||
"@playwright/test": "^1.62.0",
|
||||
"@tsconfig/node24": "^24.0.4",
|
||||
"@types/arr-diff": "^4.0.3",
|
||||
"@types/bcryptjs": "^2.4.6",
|
||||
"@types/big.js": "^6.2.2",
|
||||
"@types/big.js": "^7.0.0",
|
||||
"@types/codemirror": "^5.60.17",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/damerau-levenshtein": "^1.0.2",
|
||||
"@types/emscripten": "^1.40.1",
|
||||
"@types/emscripten": "^1.41.5",
|
||||
"@types/har-format": "^1.2.16",
|
||||
"@types/hex-array": "^1.0.2",
|
||||
"@types/js-beautify": "^1.14.3",
|
||||
"@types/jsdom": "^21.1.7",
|
||||
"@types/jsdom": "^28.0.0",
|
||||
"@types/jsonpath": "^0.2.4",
|
||||
"@types/leaflet": "^1.9.21",
|
||||
"@types/libmime": "^5.0.3",
|
||||
"@types/luxon": "^3.4.2",
|
||||
"@types/markdown-it": "^13.0.9",
|
||||
"@types/libmime": "^5.3.0",
|
||||
"@types/luxon": "^3.7.2",
|
||||
"@types/markdown-it": "^14.0.0",
|
||||
"@types/memorystream": "^0.3.4",
|
||||
"@types/mime-types": "^3.0.1",
|
||||
"@types/morsee": "^1.0.2",
|
||||
"@types/nanoid-dictionary": "^4.2.3",
|
||||
"@types/netmask": "^2.0.5",
|
||||
"@types/node": "^24.10.1",
|
||||
"@types/netmask": "^2.0.6",
|
||||
"@types/node": "^24.13.3",
|
||||
"@types/node-forge": "^1.3.14",
|
||||
"@types/picomatch": "^4.0.3",
|
||||
"@types/potrace": "^2.1.5",
|
||||
"@types/punycode": "^2.1.4",
|
||||
"@types/qrcode": "^1.5.5",
|
||||
"@types/sanitize-html": "^2.13.0",
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"@types/sanitize-html": "^2.16.1",
|
||||
"@types/spdx-satisfies": "^6.0.0",
|
||||
"@types/sshpk": "^1.17.4",
|
||||
"@types/sshpk": "^1.17.5",
|
||||
"@types/stopword": "^2.0.3",
|
||||
"@types/stringify-object": "^4.0.5",
|
||||
"@types/text-encoding-utf-8": "^1.0.5",
|
||||
"@types/turndown": "^5.0.6",
|
||||
"@types/ua-parser-js": "^0.7.39",
|
||||
"@types/unist": "^3.0.3",
|
||||
"@types/utf8": "^3.0.3",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"@vitejs/plugin-vue": "^6.0.7",
|
||||
"@vitejs/plugin-vue-jsx": "^5.1.6",
|
||||
"@vue/compiler-sfc": "^3.5.39",
|
||||
"@vue/runtime-dom": "^3.5.39",
|
||||
"@vue/test-utils": "^2.4.11",
|
||||
"@vue/tsconfig": "^0.9.1",
|
||||
"axios": "^1.16.0",
|
||||
"commander": "^14.0.1",
|
||||
"axios": "^1.18.1",
|
||||
"commander": "^15.0.0",
|
||||
"consola": "^3.4.2",
|
||||
"dotenv": "^17.2.3",
|
||||
"dotenv": "^17.4.2",
|
||||
"fast-glob": "^3.3.3",
|
||||
"hygen": "^6.2.11",
|
||||
"jsdom": "^29.1.1",
|
||||
"less": "^4.2.2",
|
||||
"less": "^4.6.7",
|
||||
"oxfmt": "^0.57.0",
|
||||
"oxlint": "^1.72.0",
|
||||
"oxlint-tsgolint": "^7.0.2001",
|
||||
"rollup-plugin-visualizer": "^7.0.1",
|
||||
"semver": "^7.7.2",
|
||||
"semver": "^7.8.5",
|
||||
"typescript": "~6.0.3",
|
||||
"unocss": "^66.7.4",
|
||||
"unocss-preset-scrollbar": "^4.0.0",
|
||||
@@ -476,12 +480,27 @@
|
||||
"vite-plugin-pwa": "^1.3.0",
|
||||
"vite-plugin-wasm": "^3.6.0",
|
||||
"vite-svg-loader": "^5.1.1",
|
||||
"vitest": "^4.1.9",
|
||||
"vitest": "^4.1.11",
|
||||
"vue-i18n-extract": "^2.0.7",
|
||||
"workbox-build": "^7.4.1",
|
||||
"workbox-window": "^7.4.1",
|
||||
"zx": "^8.8.5"
|
||||
},
|
||||
"devEngines": {
|
||||
"packageManager": {
|
||||
"name": "pnpm",
|
||||
"version": "12.6.0",
|
||||
"onFail": "download"
|
||||
},
|
||||
"runtime": {
|
||||
"name": "node",
|
||||
"version": "24.x",
|
||||
"onFail": "download"
|
||||
}
|
||||
},
|
||||
"engines": {
|
||||
"node": "24.x"
|
||||
},
|
||||
"scarfSettings": {
|
||||
"enabled": false
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
diff --git a/dist/src/shell/webParser.js b/dist/src/shell/webParser.js
|
||||
index 1b3bab1a4789e926fbe07786188d1dcddf655489..39ac6d3a8f4f5ac007d4dc1e2da272e2cc5b9088 100644
|
||||
--- a/dist/src/shell/webParser.js
|
||||
+++ b/dist/src/shell/webParser.js
|
||||
@@ -2,13 +2,17 @@
|
||||
import Parser from "web-tree-sitter";
|
||||
// NOTE: top-level await requires Safari 15+
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#browser_compatibility
|
||||
+// The wasm files are served next to the app (it-tools ships them in public/). Resolve them
|
||||
+// against the document's <base href> rather than the domain root, so the app also works
|
||||
+// when it is served from a subfolder.
|
||||
+const appBase = document.querySelector("base")?.href ?? new URL("/", location.href).href;
|
||||
await Parser.init({
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
locateFile(scriptName, scriptDirectory) {
|
||||
- return "/" + scriptName;
|
||||
+ return new URL(scriptName, appBase).href;
|
||||
},
|
||||
});
|
||||
-const Bash = await Parser.Language.load("/tree-sitter-bash.wasm");
|
||||
+const Bash = await Parser.Language.load(new URL("tree-sitter-bash.wasm", appBase).href);
|
||||
const parser = new Parser();
|
||||
parser.setLanguage(Bash);
|
||||
export default parser;
|
||||
+34
-8
@@ -1,8 +1,23 @@
|
||||
import { defineConfig, devices } from '@playwright/test';
|
||||
|
||||
const isCI = !!process.env.CI;
|
||||
const baseUrl = process.env.BASE_URL || 'http://localhost:5050';
|
||||
const useWebServer = process.env.NO_WEB_SERVER !== 'true';
|
||||
|
||||
// `pnpm preview` serves the production build here, and Playwright starts it
|
||||
// itself. Point E2E_BASE_URL somewhere else -- a running `pnpm dev`, a deployed
|
||||
// preview -- and that is taken as "I am supplying the server", so Playwright
|
||||
// leaves the lifecycle alone.
|
||||
//
|
||||
// Deliberately not BASE_URL: vite.config.ts already reads that as the app's
|
||||
// base path (`/it-tools/`), so sharing the name would make one value mean two
|
||||
// incompatible things.
|
||||
const previewUrl = 'http://localhost:5050';
|
||||
const baseUrl = process.env.E2E_BASE_URL || previewUrl;
|
||||
const useWebServer = baseUrl === previewUrl;
|
||||
|
||||
// What the browser sees is pinned by `timezoneId` below, and the specs do no
|
||||
// date maths of their own, so today this changes nothing. It keeps the runner
|
||||
// deterministic if a spec ever does compute a date on the node side.
|
||||
process.env.TZ = 'UTC';
|
||||
|
||||
/**
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
@@ -11,16 +26,22 @@ export default defineConfig({
|
||||
testDir: './src',
|
||||
testMatch: /\.e2e\.(spec\.)?ts$/,
|
||||
/* First paint of heavy lazy-loaded tools can exceed the 5s default on
|
||||
slow CI browsers (webkit especially) */
|
||||
expect: { timeout: 15_000 },
|
||||
slow CI browsers (webkit especially). Three workers share a runner, so
|
||||
first paint is slower still and CI needs more headroom than a local run.
|
||||
The test timeout has to stay above the expect timeout, otherwise it fires
|
||||
first and reports a timeout instead of the assertion that actually failed. */
|
||||
timeout: isCI ? 60_000 : 30_000,
|
||||
expect: { timeout: isCI ? 30_000 : 15_000 },
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
forbidOnly: isCI,
|
||||
/* Retry on CI only */
|
||||
retries: isCI ? 2 : 0,
|
||||
/* Opt out of parallel tests on CI. */
|
||||
workers: isCI ? 1 : undefined,
|
||||
/* CI runs one browser per job on a 4-core runner. Three workers saturates it
|
||||
(measured ~95% busy); a fourth adds nothing and leaves no core for the
|
||||
preview server. */
|
||||
workers: isCI ? 3 : undefined,
|
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||
reporter: 'html',
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
@@ -58,9 +79,14 @@ export default defineConfig({
|
||||
|
||||
...(useWebServer && {
|
||||
webServer: {
|
||||
command: 'npm run preview',
|
||||
url: 'http://localhost:5050',
|
||||
command: 'pnpm preview',
|
||||
url: previewUrl,
|
||||
reuseExistingServer: !isCI,
|
||||
// pnpm 12 runs the script in its own process group, so Playwright's
|
||||
// default SIGKILL to the `pnpm preview` group misses vite: it survives,
|
||||
// holds the output pipes open, and the run never exits. pnpm forwards
|
||||
// SIGTERM to the script, so stop it that way.
|
||||
gracefulShutdown: { signal: 'SIGTERM', timeout: 5_000 },
|
||||
},
|
||||
}),
|
||||
});
|
||||
Generated
+2392
-1671
File diff suppressed because it is too large.
Load diff
+30
-8
@@ -1,9 +1,7 @@
|
||||
# The xlsx override below intentionally points the whole graph (including
|
||||
# wsemi's transitive xlsx) at the SheetJS CDN tarball, because the npm
|
||||
# registry version is stale (0.18.5) and carries known vulnerabilities.
|
||||
# pnpm 11 blocks URL tarballs in subdependencies by default and has no
|
||||
# per-package exception, so this protection must be disabled repo-wide.
|
||||
blockExoticSubdeps: false
|
||||
# The xlsx override below points the graph at the SheetJS CDN tarball, because
|
||||
# the npm registry version is stale (0.18.5) and carries known vulnerabilities.
|
||||
# Only this package depends on xlsx now, so pnpm's default protection against
|
||||
# URL tarballs in subdependencies can stay enabled.
|
||||
|
||||
overrides:
|
||||
'@vueuse/shared': 13.9.0
|
||||
@@ -13,6 +11,9 @@ overrides:
|
||||
isolated-vm: file:./stubs/empty-stub
|
||||
onnxruntime-node: file:./stubs/empty-stub
|
||||
elliptic: ^6.6.1
|
||||
# @boxyhq/saml20 pins 0.9.10 exactly, which upstream deprecated for "critical
|
||||
# issues"; 0.9.11 is the patched release of that same line.
|
||||
'@xmldom/xmldom@0.9.10': 0.9.11
|
||||
# @it-tools/bip39 pins ^0.9.0, whose Node fallback uses eval("require('crypto')")
|
||||
# and triggers rolldown EVAL build warnings; 0.11.x dropped the eval.
|
||||
js-sha256: ^0.11.1
|
||||
@@ -22,6 +23,7 @@ patchedDependencies:
|
||||
node-forge@1.4.0: patches/node-forge@1.4.0.patch
|
||||
esm-potrace-wasm: patches/esm-potrace-wasm.patch
|
||||
run-pace: patches/run-pace.patch
|
||||
curlconverter@4.12.0: patches/curlconverter@4.12.0.patch
|
||||
|
||||
# pnpm 11 requires an explicit decision for every dependency build script.
|
||||
# true = script is needed (native binaries / functional postinstall)
|
||||
@@ -37,6 +39,26 @@ allowBuilds:
|
||||
protobufjs: false
|
||||
sharp: false
|
||||
tesseract.js: false
|
||||
tree-sitter: true
|
||||
tree-sitter-bash: true
|
||||
# Native Node bindings for curlconverter's shell parser. The app only uses
|
||||
# curlconverter in the browser, where its `browser` field swaps in
|
||||
# web-tree-sitter (WASM), so the addon is never loaded. There is no
|
||||
# linux-arm64 prebuild, and compiling it fails against Node 24's C++20 headers.
|
||||
tree-sitter: false
|
||||
tree-sitter-bash: false
|
||||
vue-demi: true
|
||||
|
||||
minimumReleaseAgeExclude:
|
||||
- phin@3.7.1
|
||||
- elliptic@6.6.2
|
||||
- file-type@21.3.1
|
||||
- unhead@2.1.11 || 2.1.13
|
||||
- dompurify@3.3.2 || 3.3.4 || 3.4.0 || 3.4.6 || 3.4.7 || 3.4.8 || 3.4.9 || 3.4.11
|
||||
- protocol-buffers-schema@3.6.1
|
||||
- '@xmldom/xmldom@0.8.14 || 0.9.11'
|
||||
- mathjs@15.2.0
|
||||
- protobufjs@7.5.5 || 7.5.6 || 7.5.8 || 7.6.1 || 7.6.3
|
||||
- underscore@1.13.8
|
||||
- ip-address@10.1.1
|
||||
- uuid@11.1.1
|
||||
- '@iplookup/country-extra@1.0.20260711'
|
||||
- nanoid@6.0.0
|
||||
@@ -0,0 +1,41 @@
|
||||
class PinkNoiseProcessor extends AudioWorkletProcessor {
|
||||
b0 = 0;
|
||||
b1 = 0;
|
||||
b2 = 0;
|
||||
b3 = 0;
|
||||
b4 = 0;
|
||||
b5 = 0;
|
||||
b6 = 0;
|
||||
|
||||
process(inputs, outputs) {
|
||||
const output = outputs[0];
|
||||
|
||||
for (const channel of output) {
|
||||
for (let i = 0; i < channel.length; i++) {
|
||||
const white = Math.random() * 2 - 1;
|
||||
|
||||
this.b0 = 0.99886 * this.b0 + white * 0.0555179;
|
||||
|
||||
this.b1 = 0.99332 * this.b1 + white * 0.0750759;
|
||||
|
||||
this.b2 = 0.969 * this.b2 + white * 0.153852;
|
||||
|
||||
this.b3 = 0.8665 * this.b3 + white * 0.3104856;
|
||||
|
||||
this.b4 = 0.55 * this.b4 + white * 0.5329522;
|
||||
|
||||
this.b5 = -0.7616 * this.b5 - white * 0.016898;
|
||||
|
||||
let pink = this.b0 + this.b1 + this.b2 + this.b3 + this.b4 + this.b5 + this.b6 + white * 0.5362;
|
||||
|
||||
this.b6 = white * 0.115926;
|
||||
|
||||
channel[i] = pink * 0.11;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
registerProcessor('pink-noise-processor', PinkNoiseProcessor);
|
||||
@@ -0,0 +1,36 @@
|
||||
class SweepProcessor extends AudioWorkletProcessor {
|
||||
phase = 0;
|
||||
position = 0;
|
||||
|
||||
startFreq = 20;
|
||||
endFreq = 20000;
|
||||
duration = 10;
|
||||
|
||||
process(inputs, outputs) {
|
||||
const output = outputs[0];
|
||||
|
||||
const totalSamples = sampleRate * this.duration;
|
||||
|
||||
for (const channel of output) {
|
||||
for (let i = 0; i < channel.length; i++) {
|
||||
const progress = this.position / totalSamples;
|
||||
|
||||
const freq = this.startFreq * Math.pow(this.endFreq / this.startFreq, progress);
|
||||
|
||||
channel[i] = Math.sin(this.phase) * 0.2;
|
||||
|
||||
this.phase += (2 * Math.PI * freq) / sampleRate;
|
||||
|
||||
this.position++;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.position >= totalSamples) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
registerProcessor('sweep-processor', SweepProcessor);
|
||||
@@ -0,0 +1,49 @@
|
||||
class ToneProcessor extends AudioWorkletProcessor {
|
||||
static get parameterDescriptors() {
|
||||
return [
|
||||
{
|
||||
name: 'frequency',
|
||||
defaultValue: 440,
|
||||
minValue: 20,
|
||||
maxValue: 20000,
|
||||
},
|
||||
{
|
||||
name: 'gain',
|
||||
defaultValue: 0.2,
|
||||
minValue: 0,
|
||||
maxValue: 1,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
phase = 0;
|
||||
|
||||
process(inputs, outputs, parameters) {
|
||||
const output = outputs[0];
|
||||
|
||||
const frequencies = parameters.frequency;
|
||||
const gains = parameters.gain;
|
||||
|
||||
for (let channel = 0; channel < output.length; channel++) {
|
||||
const data = output[channel];
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const frequency = frequencies.length > 1 ? frequencies[i] : frequencies[0];
|
||||
|
||||
const gain = gains.length > 1 ? gains[i] : gains[0];
|
||||
|
||||
data[i] = Math.sin(this.phase) * gain;
|
||||
|
||||
this.phase += (2 * Math.PI * frequency) / sampleRate;
|
||||
|
||||
if (this.phase > Math.PI * 2) {
|
||||
this.phase -= Math.PI * 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
registerProcessor('tone-processor', ToneProcessor);
|
||||
@@ -0,0 +1,15 @@
|
||||
class WhiteNoiseProcessor extends AudioWorkletProcessor {
|
||||
process(inputs, outputs) {
|
||||
const output = outputs[0];
|
||||
|
||||
for (const channel of output) {
|
||||
for (let i = 0; i < channel.length; i++) {
|
||||
channel[i] = Math.random() * 2 - 1;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
registerProcessor('white-noise-processor', WhiteNoiseProcessor);
|
||||
Binary file not shown.
@@ -33,7 +33,7 @@ function escapeHtml(text) {
|
||||
'"': '"',
|
||||
"'": '''
|
||||
};
|
||||
return text.replace(/[&<>"']/g, char => map[char]);
|
||||
return String(text).replace(/[&<>"']/g, char => map[char]);
|
||||
}
|
||||
|
||||
// Helper function to generate HTML table from table data array
|
||||
@@ -1139,7 +1139,7 @@ function reset() {
|
||||
let rootNetwork = get_network($('#network').val(), $('#netsize').val())
|
||||
let rootCidr = rootNetwork + '/' + $('#netsize').val()
|
||||
if (cidrInput !== rootCidr) {
|
||||
show_warning_modal('<div>Your network input is not on a network boundary for this network size. It has been automatically changed:</div><div class="font-monospace pt-2">' + $('#network').val() + ' -> ' + rootNetwork + '</div>')
|
||||
show_warning_modal('<div>Your network input is not on a network boundary for this network size. It has been automatically changed:</div><div class="font-monospace pt-2">' + escapeHtml($('#network').val()) + ' -> ' + escapeHtml(rootNetwork) + '</div>')
|
||||
$('#network').val(rootNetwork)
|
||||
cidrInput = $('#network').val() + '/' + $('#netsize').val()
|
||||
}
|
||||
@@ -1264,6 +1264,13 @@ function addRowTree(subnetTree, depth, maxDepth, operatingMode) {
|
||||
}
|
||||
|
||||
function addRow(network, netSize, colspan, note, notesWidth, color, operatingMode) {
|
||||
// The subnet map can come from a shareable URL or an imported config, so escape everything that lands in HTML
|
||||
const rawNetwork = network
|
||||
network = escapeHtml(network)
|
||||
note = escapeHtml(note)
|
||||
if (!/^#[0-9a-f]{3,8}$/i.test(color)) {
|
||||
color = ''
|
||||
}
|
||||
let addressFirst = ip2int(network)
|
||||
let addressLast = subnet_last_address(addressFirst, netSize)
|
||||
let usableFirst = subnet_usable_first(addressFirst, netSize, operatingMode)
|
||||
@@ -1317,10 +1324,10 @@ function addRow(network, netSize, colspan, note, notesWidth, color, operatingMod
|
||||
// DONE: If the subnet address (without the mask) matches a larger subnet address
|
||||
// in the heirarchy that is a signal to add more join buttons to that row, since they start at the top row and
|
||||
// via rowspan extend downward.
|
||||
let matchingNetworkList = get_matching_network_list(network, subnetMap).slice(1)
|
||||
let matchingNetworkList = get_matching_network_list(rawNetwork, subnetMap).slice(1)
|
||||
for (const i in matchingNetworkList) {
|
||||
let matchingNetwork = matchingNetworkList[i]
|
||||
let networkChildrenCount = count_network_children(matchingNetwork, subnetMap, [])
|
||||
let networkChildrenCount = count_network_children(matchingNetworkList[i], subnetMap, [])
|
||||
let matchingNetwork = escapeHtml(matchingNetworkList[i])
|
||||
newRow += ' <td aria-label="' + matchingNetwork + ' Join" rowspan="' + networkChildrenCount + '" colspan="1" class="join rotate" data-subnet="' + matchingNetwork + '" data-mutate-verb="join"><span>/' + matchingNetwork.split('/')[1] + '</span></td>\n'
|
||||
}
|
||||
}
|
||||
@@ -2281,7 +2288,7 @@ $('#btn_auto_allocate').on('click', function() {
|
||||
if (subnetRequests.errors) {
|
||||
let errorHtml = '<div class="alert alert-danger"><strong>Subnet Requirements Errors:</strong><ul class="mb-0">';
|
||||
for (const error of subnetRequests.errors) {
|
||||
errorHtml += `<li>${error}</li>`;
|
||||
errorHtml += `<li>${escapeHtml(error)}</li>`;
|
||||
}
|
||||
errorHtml += '</ul></div>';
|
||||
$('#allocation_results').html(errorHtml);
|
||||
@@ -2464,7 +2471,7 @@ $('#btn_auto_allocate').on('click', function() {
|
||||
if (allocations.length > 0) {
|
||||
resultsHtml += '<div class="alert alert-success"><h6>Allocated Subnets:</h6><ul class="mb-0">';
|
||||
for (const alloc of allocations) {
|
||||
resultsHtml += `<li><strong>${alloc.name}:</strong> ${alloc.cidr}</li>`;
|
||||
resultsHtml += `<li><strong>${escapeHtml(alloc.name)}:</strong> ${escapeHtml(alloc.cidr)}</li>`;
|
||||
}
|
||||
resultsHtml += '</ul></div>';
|
||||
|
||||
@@ -2557,7 +2564,7 @@ $('#btn_auto_allocate').on('click', function() {
|
||||
if (allocationErrors.length > 0) {
|
||||
resultsHtml += '<div class="alert alert-danger"><h6>Errors:</h6><ul class="mb-0">';
|
||||
for (const error of allocationErrors) {
|
||||
resultsHtml += `<li>${error}</li>`;
|
||||
resultsHtml += `<li>${escapeHtml(error)}</li>`;
|
||||
}
|
||||
resultsHtml += '</ul></div>';
|
||||
}
|
||||
@@ -2565,7 +2572,7 @@ $('#btn_auto_allocate').on('click', function() {
|
||||
$('#allocation_results').html(resultsHtml);
|
||||
} catch (error) {
|
||||
console.error('Auto-allocation error:', error);
|
||||
$('#allocation_results').html('<div class="alert alert-danger">An error occurred during allocation: ' + error.message + '</div>');
|
||||
$('#allocation_results').html('<div class="alert alert-danger">An error occurred during allocation: ' + escapeHtml(error.message) + '</div>');
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
@@ -2665,14 +2672,14 @@ $('#btn_validate_alignment').on('click', function() {
|
||||
if (issues.length > 0) {
|
||||
resultsHtml += '<div class="alert alert-danger"><h6>Issues Found:</h6><ul class="mb-0">';
|
||||
for (const issue of issues) {
|
||||
resultsHtml += `<li>${issue}</li>`;
|
||||
resultsHtml += `<li>${escapeHtml(issue)}</li>`;
|
||||
}
|
||||
resultsHtml += '</ul></div>';
|
||||
}
|
||||
if (warnings.length > 0) {
|
||||
resultsHtml += '<div class="alert alert-warning"><h6>Gaps Detected:</h6><ul class="mb-0">';
|
||||
for (const warning of warnings) {
|
||||
resultsHtml += `<li>${warning}</li>`;
|
||||
resultsHtml += `<li>${escapeHtml(warning)}</li>`;
|
||||
}
|
||||
resultsHtml += '</ul></div>';
|
||||
}
|
||||
|
||||
@@ -1255,9 +1255,9 @@ $(document).ready(function() {
|
||||
$("input#add_vdev").val("");
|
||||
|
||||
if (new_vdev_type == "mirror") {
|
||||
$("td#status").html(new_vdev_width + "-way mirror added");
|
||||
$("td#status").text(new_vdev_width + "-way mirror added");
|
||||
} else {
|
||||
$("td#status").html(new_vdev_width + "-wide " + new_vdev_type.toUpperCase() + " added");
|
||||
$("td#status").text(new_vdev_width + "-wide " + new_vdev_type.toUpperCase() + " added");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-7
@@ -20,7 +20,7 @@
|
||||
"packageRules": [
|
||||
{
|
||||
"groupName": "TypeScript toolchain",
|
||||
"matchPackageNames": ["typescript", "vue-tsc"],
|
||||
"matchPackageNames": ["typescript", "vue-tsc", "oxlint-tsgolint"],
|
||||
"matchUpdateTypes": ["major", "minor", "patch"]
|
||||
},
|
||||
{
|
||||
@@ -73,17 +73,12 @@
|
||||
"matchPackageNames": ["@vueuse/core", "@vueuse/head", "@vueuse/router"],
|
||||
"matchUpdateTypes": ["major", "minor", "patch"]
|
||||
},
|
||||
{
|
||||
"groupName": "uuid with types",
|
||||
"matchPackageNames": ["uuid", "@types/uuid"],
|
||||
"matchUpdateTypes": ["major", "minor", "patch"]
|
||||
},
|
||||
{
|
||||
"groupName": "Type packages with their dependencies",
|
||||
"matchDepTypes": ["devDependencies"],
|
||||
"groupSlug": "types",
|
||||
"automerge": true,
|
||||
"matchPackageNames": ["/^@types//", "!@types/uuid"]
|
||||
"matchPackageNames": ["/^@types//"]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -11,29 +11,42 @@ if (fs.existsSync(localesFile)) {
|
||||
localesData = yaml.parse(fs.readFileSync(localesFile, 'utf-8')) || {};
|
||||
}
|
||||
|
||||
// Single-quoted JS string that may contain escaped quotes. `[^'\\]|\\.` cannot overlap, so it cannot backtrack exponentially.
|
||||
const quotedValue = (key) => new RegExp(`\\b${key}:[ \n]+'((?:[^'\\\\]|\\\\.)*)'`);
|
||||
// Decode JS string escapes (\n, \x27, \u00e9, \u{1F600}, \') the way the JS parser would
|
||||
const JS_ESCAPES = { n: '\n', r: '\r', t: '\t', b: '\b', f: '\f', v: '\v', 0: '\0' };
|
||||
const unescapeValue = (value) =>
|
||||
value.replace(/\\(?:u\{([\da-fA-F]+)\}|u([\da-fA-F]{4})|x([\da-fA-F]{2})|(.))/g, (_, codePoint, u4, x2, char) =>
|
||||
char === undefined ? String.fromCodePoint(Number.parseInt(codePoint ?? u4 ?? x2, 16)) : (JS_ESCAPES[char] ?? char),
|
||||
);
|
||||
|
||||
function processFile(filePath) {
|
||||
const parentDir = path.basename(path.dirname(filePath)); // Get parent directory name
|
||||
const originalContent = fs.readFileSync(filePath, 'utf-8');
|
||||
|
||||
// Extract existing name and description values
|
||||
const nameMatch = originalContent.match(/name: '(.*?)'/);
|
||||
const descriptionMatch = originalContent.match(/description: '(.*?)'/);
|
||||
const externAccessDescriptionMatch = originalContent.match(/externAccessDescription: '(.*?)'/);
|
||||
const nameMatch = originalContent.match(quotedValue('name'));
|
||||
const descriptionMatch = originalContent.match(quotedValue('description'));
|
||||
const externAccessDescriptionMatch = originalContent.match(quotedValue('externAccessDescription'));
|
||||
|
||||
if (!nameMatch || !descriptionMatch) {
|
||||
console.warn(`Skipping ${filePath}: Unable to extract name or description.`);
|
||||
console.warn(
|
||||
`Skipping ${filePath}: Unable to extract name (${nameMatch ? 'found' : 'not found'}) or description (${descriptionMatch ? 'found' : 'not found'}).`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const nameValue = nameMatch[1];
|
||||
const descriptionValue = descriptionMatch[1];
|
||||
const externAccessDescriptionValue = externAccessDescriptionMatch ? externAccessDescriptionMatch[1] : null;
|
||||
const nameValue = unescapeValue(nameMatch[1]);
|
||||
const descriptionValue = unescapeValue(descriptionMatch[1]);
|
||||
const externAccessDescriptionValue = externAccessDescriptionMatch
|
||||
? unescapeValue(externAccessDescriptionMatch[1])
|
||||
: null;
|
||||
|
||||
// Modify name and description to use the translate function
|
||||
const transformedContent = originalContent
|
||||
.replace(/name: '((?:[^']+|(?<=\\)')+)'/, `name: t('tools.${parentDir}.title')`)
|
||||
.replace(/description: '((?:[^']+|(?<=\\)')+)'/, `description: t('tools.${parentDir}.description')`)
|
||||
.replace(/externAccessDescription: '((?:[^']+|(?<=\\)')+)'/, `externAccessDescription: t('tools.${parentDir}.externalAccess')`);
|
||||
.replace(quotedValue('name'), `name: t('tools.${parentDir}.title')`)
|
||||
.replace(quotedValue('description'), `description: t('tools.${parentDir}.description')`)
|
||||
.replace(quotedValue('externAccessDescription'), `externAccessDescription: t('tools.${parentDir}.externalAccess')`);
|
||||
|
||||
fs.writeFileSync(filePath, `import { translate as t } from '@/plugins/i18n.plugin';\n${transformedContent}`, 'utf-8');
|
||||
console.log(`Transformed: ${filePath}`);
|
||||
@@ -59,8 +72,7 @@ function iterateFolder(folderPath) {
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
iterateFolder(itemPath);
|
||||
}
|
||||
else if (item === 'index.ts') {
|
||||
} else if (item === 'index.ts') {
|
||||
processFile(itemPath);
|
||||
}
|
||||
});
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ try {
|
||||
consola.success('Changelog changes committed');
|
||||
|
||||
consola.info('Creating version and tag');
|
||||
await $`npm version ${version} -m "chore(version): release ${version}"`;
|
||||
await $`pnpm version ${version} -m "chore(version): release ${version}"`;
|
||||
consola.info('Npm version released with tag');
|
||||
} catch (error) {
|
||||
consola.error(error);
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
// Downloads every template of github/gitignore and alexkaratarakis/gitattributes into JSON snapshots that the
|
||||
// gitignore and gitattributes generators fall back to when offline or when GitHub can't be reached.
|
||||
// Usage: pnpm script:update:git-templates (set GITHUB_TOKEN to avoid the unauthenticated API rate limit)
|
||||
import fs from 'node:fs/promises';
|
||||
|
||||
const sources = [
|
||||
{
|
||||
repository: 'github/gitignore',
|
||||
ref: 'main',
|
||||
extension: '.gitignore',
|
||||
output: 'src/tools/gitignore-generator/gitignore-templates.json',
|
||||
},
|
||||
{
|
||||
repository: 'alexkaratarakis/gitattributes',
|
||||
ref: 'master',
|
||||
extension: '.gitattributes',
|
||||
output: 'src/tools/gitattributes-generator/gitattributes-templates.json',
|
||||
},
|
||||
];
|
||||
|
||||
const CONCURRENCY = 8;
|
||||
|
||||
const apiHeaders = {
|
||||
Accept: 'application/vnd.github+json',
|
||||
...(process.env.GITHUB_TOKEN ? { Authorization: `Bearer ${process.env.GITHUB_TOKEN}` } : {}),
|
||||
};
|
||||
|
||||
async function fetchOk(url, init) {
|
||||
const response = await fetch(url, init);
|
||||
if (!response.ok) {
|
||||
throw new Error(`${url}: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
async function snapshot({ repository, ref, extension, output }) {
|
||||
const commit = await (
|
||||
await fetchOk(`https://api.github.com/repos/${repository}/commits/${ref}`, { headers: apiHeaders })
|
||||
).json();
|
||||
const tree = await (
|
||||
await fetchOk(`https://api.github.com/repos/${repository}/git/trees/${commit.sha}?recursive=true`, {
|
||||
headers: apiHeaders,
|
||||
})
|
||||
).json();
|
||||
if (tree.truncated) {
|
||||
throw new Error(`${repository}: tree listing is truncated`);
|
||||
}
|
||||
|
||||
// Same name derivation as the tools: the path without its extension, skipping a bare root dotfile
|
||||
const names = tree.tree
|
||||
.filter(({ type, path }) => type === 'blob' && path.endsWith(extension))
|
||||
.map(({ path }) => path.slice(0, -extension.length))
|
||||
.filter(Boolean)
|
||||
.sort((a, b) => a.localeCompare(b));
|
||||
|
||||
const templates = {};
|
||||
for (let i = 0; i < names.length; i += CONCURRENCY) {
|
||||
const batch = names.slice(i, i + CONCURRENCY);
|
||||
const contents = await Promise.all(
|
||||
batch.map(async (name) =>
|
||||
(await fetchOk(`https://raw.githubusercontent.com/${repository}/${commit.sha}/${name}${extension}`)).text(),
|
||||
),
|
||||
);
|
||||
batch.forEach((name, index) => (templates[name] = contents[index]));
|
||||
}
|
||||
|
||||
const data = { repository, ref, commit: commit.sha, date: commit.commit.committer.date, templates };
|
||||
await fs.writeFile(output, `${JSON.stringify(data, null, 2)}\n`);
|
||||
const size = (await fs.stat(output)).size;
|
||||
console.log(`${output}: ${names.length} templates from ${repository}@${commit.sha.slice(0, 7)} (${size} bytes)`);
|
||||
}
|
||||
|
||||
for (const source of sources) {
|
||||
await snapshot(source);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
memory=$(sysctl -n hw.memsize)
|
||||
memory=$((memory / 1024 / 1024))
|
||||
else
|
||||
memory=$(awk '/MemTotal/{print $2}' /proc/meminfo)
|
||||
memory=$((memory / 1024))
|
||||
fi
|
||||
|
||||
node_options="--max-old-space-size=$((memory - 1024))"
|
||||
|
||||
echo "NODE_OPTIONS=$node_options"
|
||||
export NODE_OPTIONS="$node_options"
|
||||
+9
-7
@@ -3,6 +3,7 @@ import { RouterView, useRoute } from 'vue-router';
|
||||
import { NGlobalStyle, NMessageProvider, NNotificationProvider, darkTheme } from 'naive-ui';
|
||||
import { get } from '@vueuse/core';
|
||||
import { darkThemeOverrides, lightThemeOverrides } from './themes';
|
||||
import BaseLayout from './layouts/base.layout.vue';
|
||||
import { layouts } from './layouts';
|
||||
import { useStyleStore } from './stores/style.store';
|
||||
import { useAppTheme } from './ui/theme/themes';
|
||||
@@ -43,10 +44,7 @@ watchEffect(() => {
|
||||
|
||||
locale.value = get(getITToolsSetting('default_locale', locale.value));
|
||||
|
||||
syncRef(
|
||||
locale,
|
||||
useStorage('locale', locale),
|
||||
);
|
||||
syncRef(locale, useStorage('locale', locale));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -55,9 +53,13 @@ syncRef(
|
||||
<NMessageProvider placement="bottom">
|
||||
<NNotificationProvider placement="bottom-right">
|
||||
<div class="app-root">
|
||||
<component :is="layout">
|
||||
<RouterView />
|
||||
</component>
|
||||
<!-- Wraps the switch: inside it, this is to prevent moving between a plain and a tool route
|
||||
tearing down down the sider and remounted its ~460 menu items. -->
|
||||
<BaseLayout>
|
||||
<component :is="layout">
|
||||
<RouterView />
|
||||
</component>
|
||||
</BaseLayout>
|
||||
</div>
|
||||
</NNotificationProvider>
|
||||
</NMessageProvider>
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
import { createReadStream, existsSync, readFileSync, statSync } from 'node:fs';
|
||||
import { createServer } from 'node:http';
|
||||
import type { Server } from 'node:http';
|
||||
import { extname, join, normalize, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
// The app is built once, for no particular path, and told where it lives at request time.
|
||||
// This exercises that: a server that mounts `dist` under a subfolder the way the container
|
||||
// does -- rewrite the one `<base href>` in index.html, serve everything else from the same
|
||||
// files -- and then checks the app actually works from there.
|
||||
//
|
||||
// See nginx.conf (the real thing), vite.config.ts (`base` and the baseHref plugin) and
|
||||
// src/utils/base-url.ts (how the app reads it back).
|
||||
|
||||
const BASE_URL = '/it-tools/';
|
||||
const DIST = resolve(fileURLToPath(new URL('.', import.meta.url)), '../dist');
|
||||
|
||||
const CONTENT_TYPES: Record<string, string> = {
|
||||
'.css': 'text/css',
|
||||
'.html': 'text/html',
|
||||
'.ico': 'image/x-icon',
|
||||
'.js': 'text/javascript',
|
||||
'.json': 'application/json',
|
||||
'.md': 'text/markdown',
|
||||
'.mjs': 'text/javascript',
|
||||
'.png': 'image/png',
|
||||
'.svg': 'image/svg+xml',
|
||||
'.wasm': 'application/wasm',
|
||||
'.webmanifest': 'application/manifest+json',
|
||||
};
|
||||
|
||||
function resolveInDist(pathname: string): string | undefined {
|
||||
const candidate = join(DIST, normalize(pathname));
|
||||
|
||||
if (!candidate.startsWith(DIST) || !existsSync(candidate) || !statSync(candidate).isFile()) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
function serveDistUnder(base: string): Promise<{ server: Server; origin: string }> {
|
||||
// What nginx.conf does with sub_filter, on every HTML response rather than only on the
|
||||
// SPA fallback: the service worker precaches index.html by fetching it, and it has to
|
||||
// get the same document a navigation would.
|
||||
const withBaseHref = (html: string) => html.replace('<base href="/">', `<base href="${base}">`);
|
||||
const indexHtml = withBaseHref(readFileSync(join(DIST, 'index.html'), 'utf-8'));
|
||||
|
||||
const server = createServer((request, response) => {
|
||||
const { pathname } = new URL(request.url ?? '/', 'http://localhost');
|
||||
// Everything below the mount point, with the prefix dropped -- the reverse proxy in
|
||||
// front of a container may or may not have stripped it already, so nginx.conf copes
|
||||
// with both and so does this.
|
||||
const path = decodeURIComponent(pathname.startsWith(base) ? pathname.slice(base.length - 1) : pathname);
|
||||
|
||||
const asset = path.match(/^\/(?:.*\/)?assets\/(.+)$/);
|
||||
const file = asset ? resolveInDist(`/assets/${asset[1]}`) : resolveInDist(path);
|
||||
|
||||
if (!file) {
|
||||
// A missing hashed chunk is a 404, not the SPA shell: serving index.html in its
|
||||
// place turns a plain 404 into an opaque MIME error in the browser.
|
||||
if (asset) {
|
||||
response.writeHead(404).end();
|
||||
return;
|
||||
}
|
||||
|
||||
response.writeHead(200, { 'content-type': 'text/html' }).end(indexHtml);
|
||||
return;
|
||||
}
|
||||
|
||||
response.writeHead(200, {
|
||||
'content-type': CONTENT_TYPES[extname(file)] ?? 'application/octet-stream',
|
||||
// Same headers the container sets; the WebAssembly-backed tools need them.
|
||||
'cross-origin-opener-policy': 'same-origin',
|
||||
'cross-origin-embedder-policy': 'require-corp',
|
||||
});
|
||||
|
||||
if (extname(file) === '.html') {
|
||||
response.end(withBaseHref(readFileSync(file, 'utf-8')));
|
||||
return;
|
||||
}
|
||||
|
||||
createReadStream(file).pipe(response);
|
||||
});
|
||||
|
||||
return new Promise((done) => {
|
||||
server.listen(0, '127.0.0.1', () => {
|
||||
const address = server.address();
|
||||
const port = typeof address === 'object' && address !== null ? address.port : 0;
|
||||
|
||||
done({ server, origin: `http://127.0.0.1:${port}` });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
test.describe('Deployment under a subfolder', () => {
|
||||
let server: Server;
|
||||
let origin: string;
|
||||
|
||||
test.beforeAll(async () => {
|
||||
({ server, origin } = await serveDistUnder(BASE_URL));
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
await new Promise((done) => server.close(done));
|
||||
});
|
||||
|
||||
test('loads the app, and everything it asks for, from the subfolder', async ({ page }) => {
|
||||
const notFound: string[] = [];
|
||||
page.on('response', (response) => {
|
||||
if (response.status() === 404 && response.url().startsWith(origin)) {
|
||||
notFound.push(response.url());
|
||||
}
|
||||
});
|
||||
|
||||
await page.goto(`${origin}${BASE_URL}`);
|
||||
|
||||
await expect(page).toHaveTitle(/IT Tools/);
|
||||
// Router links carry the subfolder, so navigating inside the app stays inside it.
|
||||
await expect(page.locator(`a[href^="${BASE_URL}"]`).first()).toBeVisible();
|
||||
expect(notFound).toEqual([]);
|
||||
});
|
||||
|
||||
test('serves a deep link, whose assets are one directory further down', async ({ page }) => {
|
||||
// The interesting case for a relative build: index.html is served for a path that is
|
||||
// not the app root, so `./assets/...` would resolve one level too deep without the
|
||||
// `<base href>` the server injected.
|
||||
await page.goto(`${origin}${BASE_URL}json-to-yaml-converter`);
|
||||
|
||||
await expect(page).toHaveTitle('JSON to YAML converter - IT Tools');
|
||||
|
||||
// Reaching the tool at all means its lazily imported chunk was resolved correctly.
|
||||
await page.getByTestId('input').fill('{"foo":"bar"}');
|
||||
expect((await page.getByTestId('area-content').innerText()).trim()).toEqual('foo: bar');
|
||||
});
|
||||
|
||||
test('keeps the subfolder when navigating and reloading', async ({ page }) => {
|
||||
await page.goto(`${origin}${BASE_URL}`);
|
||||
|
||||
const homeTitle = await page.title();
|
||||
await page.locator('a.it-tool-link').first().click();
|
||||
|
||||
// The router was handed the runtime base, so an in-app navigation writes a URL that
|
||||
// still points inside the subfolder -- and reloading it lands back on the same tool
|
||||
// instead of on the app root or a 404.
|
||||
await expect(page).not.toHaveURL(`${origin}${BASE_URL}`);
|
||||
expect(page.url().startsWith(`${origin}${BASE_URL}`)).toBe(true);
|
||||
|
||||
await expect(page).not.toHaveTitle(homeTitle);
|
||||
|
||||
const url = page.url();
|
||||
const title = await page.title();
|
||||
|
||||
// Then load that URL from scratch, the way someone pasting the link would: it has to
|
||||
// come back as the same tool rather than as the app root or a 404. In a second tab
|
||||
// rather than by reloading this one -- navigating a page that has just pulled in a
|
||||
// tool's chunks races with those requests, and the app answers an aborted chunk load
|
||||
// by reloading itself (the vite:preloadError handler in src/main.ts), which cancels
|
||||
// the navigation the test is waiting on.
|
||||
const fresh = await page.context().newPage();
|
||||
await fresh.goto(url);
|
||||
|
||||
await expect(fresh).toHaveURL(url);
|
||||
await expect(fresh).toHaveTitle(title);
|
||||
await fresh.close();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,135 @@
|
||||
<script setup lang="ts">
|
||||
import { useThemeVars } from 'naive-ui';
|
||||
import { formatSignalNumber } from '@/utils/analog-signal';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
min: number;
|
||||
max: number;
|
||||
value: number;
|
||||
unit?: string;
|
||||
status?: 'ok' | 'warning' | 'error';
|
||||
}>(),
|
||||
{
|
||||
unit: '',
|
||||
status: 'ok',
|
||||
},
|
||||
);
|
||||
|
||||
const themeVars = useThemeVars();
|
||||
|
||||
const isValid = computed(() => Number.isFinite(props.min) && Number.isFinite(props.max) && props.min !== props.max);
|
||||
|
||||
// Position in the range, in percent; may go outside of 0-100 when the value is out of range.
|
||||
const percent = computed(() =>
|
||||
isValid.value && Number.isFinite(props.value)
|
||||
? ((props.value - props.min) / (props.max - props.min)) * 100
|
||||
: Number.NaN,
|
||||
);
|
||||
const clampedPercent = computed(() => (Number.isFinite(percent.value) ? Math.min(100, Math.max(0, percent.value)) : 0));
|
||||
const isOutOfRange = computed(() => percent.value < 0 || percent.value > 100);
|
||||
|
||||
const fillColor = computed(
|
||||
() =>
|
||||
({
|
||||
ok: themeVars.value.primaryColor,
|
||||
warning: themeVars.value.warningColor,
|
||||
error: themeVars.value.errorColor,
|
||||
})[props.status],
|
||||
);
|
||||
|
||||
const withUnit = (value: number) => `${formatSignalNumber(value)}${props.unit ? ` ${props.unit}` : ''}`;
|
||||
const middle = computed(() => (props.min + props.max) / 2);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="analog-gauge" :class="{ 'out-of-range': isOutOfRange }" data-test-id="gauge">
|
||||
<div class="scale">
|
||||
<span>{{ withUnit(max) }}</span>
|
||||
<span>{{ withUnit(middle) }}</span>
|
||||
<span>{{ withUnit(min) }}</span>
|
||||
</div>
|
||||
|
||||
<div class="tube" role="meter" :aria-valuemin="min" :aria-valuemax="max" :aria-valuenow="value">
|
||||
<div class="fill" :style="{ height: `${clampedPercent}%`, backgroundColor: fillColor }" />
|
||||
<div class="tick" style="bottom: 25%" />
|
||||
<div class="tick" style="bottom: 50%" />
|
||||
<div class="tick" style="bottom: 75%" />
|
||||
</div>
|
||||
|
||||
<div class="marker-track">
|
||||
<div v-if="Number.isFinite(percent)" class="marker" :style="{ bottom: `${clampedPercent}%`, color: fillColor }">
|
||||
◄ {{ formatSignalNumber(percent, 1) }} %
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="less">
|
||||
.analog-gauge {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
height: 200px;
|
||||
margin: 16px 0;
|
||||
|
||||
.scale {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
align-items: flex-end;
|
||||
font-size: 12px;
|
||||
opacity: 0.7;
|
||||
white-space: nowrap;
|
||||
// Labels sit on the top, middle and bottom lines of the tube
|
||||
margin: -8px 0;
|
||||
}
|
||||
|
||||
.tube {
|
||||
position: relative;
|
||||
width: 28px;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
background-color: v-bind('themeVars.buttonColor2');
|
||||
border: 1px solid v-bind('themeVars.borderColor');
|
||||
|
||||
.fill {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
transition:
|
||||
height 0.25s ease-out,
|
||||
background-color 0.25s;
|
||||
}
|
||||
|
||||
.tick {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
width: 8px;
|
||||
height: 1px;
|
||||
background-color: v-bind('themeVars.textColor3');
|
||||
}
|
||||
}
|
||||
|
||||
.marker-track {
|
||||
position: relative;
|
||||
width: 72px;
|
||||
|
||||
.marker {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
transform: translateY(50%);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
transition: bottom 0.25s ease-out;
|
||||
}
|
||||
}
|
||||
|
||||
&.out-of-range .tube {
|
||||
border-color: v-bind('fillColor');
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,468 @@
|
||||
<script setup lang="ts">
|
||||
import { useStorage } from '@vueuse/core';
|
||||
import { useThemeVars } from 'naive-ui';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import AnalogGauge from './AnalogGauge.vue';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
import {
|
||||
type SignalRange,
|
||||
formatSignalNumber,
|
||||
getCurrentLoopStatus,
|
||||
getLinearTransform,
|
||||
getSignalRangeStatus,
|
||||
scaleValue,
|
||||
} from '@/utils/analog-signal';
|
||||
|
||||
export interface SignalPreset {
|
||||
label: string;
|
||||
min: number;
|
||||
max: number;
|
||||
}
|
||||
|
||||
type Direction = 'signal-to-value' | 'value-to-signal';
|
||||
type Side = 'signal' | 'engineering';
|
||||
interface SideStatus {
|
||||
type: 'ok' | 'warning' | 'error';
|
||||
message: string;
|
||||
}
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
storageKey: string;
|
||||
signalLabel: string;
|
||||
signalUnit?: string;
|
||||
presets: SignalPreset[];
|
||||
defaultEngineering?: SignalRange & { unit: string };
|
||||
// The signal is an integer register (raw PLC value): also show the rounded value.
|
||||
integerSignal?: boolean;
|
||||
// Apply the NAMUR NE 43 diagnostic when the signal range is 4-20 mA.
|
||||
currentLoopDiagnostic?: boolean;
|
||||
}>(),
|
||||
{
|
||||
signalUnit: '',
|
||||
defaultEngineering: () => ({ min: 0, max: 100, unit: '%' }),
|
||||
integerSignal: false,
|
||||
currentLoopDiagnostic: false,
|
||||
},
|
||||
);
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const themeVars = useThemeVars();
|
||||
|
||||
const defaultPreset = props.presets[0] ?? { label: '', min: 0, max: 10 };
|
||||
|
||||
const signalMin = useStorage<number | null>(`${props.storageKey}:signal-min`, defaultPreset.min);
|
||||
const signalMax = useStorage<number | null>(`${props.storageKey}:signal-max`, defaultPreset.max);
|
||||
const engineeringMin = useStorage<number | null>(`${props.storageKey}:engineering-min`, props.defaultEngineering.min);
|
||||
const engineeringMax = useStorage<number | null>(`${props.storageKey}:engineering-max`, props.defaultEngineering.max);
|
||||
const engineeringUnit = useStorage(`${props.storageKey}:engineering-unit`, props.defaultEngineering.unit);
|
||||
const direction = useStorage<Direction>(`${props.storageKey}:direction`, 'signal-to-value');
|
||||
|
||||
const toNumber = (value: number | null | undefined) => (typeof value === 'number' ? value : Number.NaN);
|
||||
|
||||
const signalRange = computed<SignalRange>(() => ({ min: toNumber(signalMin.value), max: toNumber(signalMax.value) }));
|
||||
const engineeringRange = computed<SignalRange>(() => ({
|
||||
min: toNumber(engineeringMin.value),
|
||||
max: toNumber(engineeringMax.value),
|
||||
}));
|
||||
const rangeOf = (side: Side) => (side === 'signal' ? signalRange.value : engineeringRange.value);
|
||||
const unitOf = (side: Side) => (side === 'signal' ? props.signalUnit : engineeringUnit.value);
|
||||
const labelOf = (side: Side) =>
|
||||
side === 'signal' ? props.signalLabel : t('analogSignalConverter.texts.label-engineering-value');
|
||||
|
||||
const inputSide = computed<Side>(() => (direction.value === 'signal-to-value' ? 'signal' : 'engineering'));
|
||||
const outputSide = computed<Side>(() => (direction.value === 'signal-to-value' ? 'engineering' : 'signal'));
|
||||
|
||||
const midpoint = ({ min, max }: SignalRange) => (min + max) / 2;
|
||||
const inputValue = ref<number | null>(midpoint(rangeOf(inputSide.value)));
|
||||
|
||||
// Min must be strictly lower than max: an inverted range is almost always a typo.
|
||||
const isRangeValid = (range: SignalRange) =>
|
||||
Number.isFinite(range.min) && Number.isFinite(range.max) && range.min < range.max;
|
||||
|
||||
const isSignalRangeInvalid = computed(() => !isRangeValid(signalRange.value));
|
||||
const isEngineeringRangeInvalid = computed(() => !isRangeValid(engineeringRange.value));
|
||||
|
||||
const rangesError = computed(() => {
|
||||
if (!isRangeValid(signalRange.value)) {
|
||||
return t('analogSignalConverter.texts.error-signal-range');
|
||||
}
|
||||
if (!isRangeValid(engineeringRange.value)) {
|
||||
return t('analogSignalConverter.texts.error-engineering-range');
|
||||
}
|
||||
return '';
|
||||
});
|
||||
|
||||
const outputValue = computed(() => {
|
||||
const value = toNumber(inputValue.value);
|
||||
if (rangesError.value || !Number.isFinite(value)) {
|
||||
return Number.NaN;
|
||||
}
|
||||
return scaleValue({ value, from: rangeOf(inputSide.value), to: rangeOf(outputSide.value) });
|
||||
});
|
||||
|
||||
const valueOf = (side: Side) => (side === inputSide.value ? toNumber(inputValue.value) : outputValue.value);
|
||||
|
||||
// Swapping keeps the current operating point: the output becomes the new input.
|
||||
function swapDirection() {
|
||||
const previousOutput = outputValue.value;
|
||||
direction.value = direction.value === 'signal-to-value' ? 'value-to-signal' : 'signal-to-value';
|
||||
inputValue.value = Number.isFinite(previousOutput)
|
||||
? Number(formatSignalNumber(previousOutput))
|
||||
: midpoint(rangeOf(inputSide.value));
|
||||
}
|
||||
|
||||
const CUSTOM_PRESET = 'custom';
|
||||
const presetOptions = computed(() => [
|
||||
...props.presets.map(({ label }, index) => ({ label, value: String(index) })),
|
||||
{ label: t('analogSignalConverter.texts.preset-custom'), value: CUSTOM_PRESET },
|
||||
]);
|
||||
|
||||
const selectedPreset = computed({
|
||||
get() {
|
||||
const index = props.presets.findIndex(({ min, max }) => min === signalMin.value && max === signalMax.value);
|
||||
return index === -1 ? CUSTOM_PRESET : String(index);
|
||||
},
|
||||
set(value: string) {
|
||||
const preset = props.presets[Number(value)];
|
||||
if (preset) {
|
||||
signalMin.value = preset.min;
|
||||
signalMax.value = preset.max;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const isCurrentLoop = computed(
|
||||
() => props.currentLoopDiagnostic && signalRange.value.min === 4 && signalRange.value.max === 20,
|
||||
);
|
||||
|
||||
function getSignalStatus(value: number): SideStatus {
|
||||
if (isCurrentLoop.value) {
|
||||
const status = getCurrentLoopStatus(value);
|
||||
if (status === 'ok') {
|
||||
return { type: 'ok', message: t('analogSignalConverter.texts.status-ok') };
|
||||
}
|
||||
return {
|
||||
type: status.startsWith('failure') ? 'error' : 'warning',
|
||||
message: t(`analogSignalConverter.texts.loop-status-${status}`),
|
||||
};
|
||||
}
|
||||
|
||||
const status = getSignalRangeStatus({ value, range: signalRange.value });
|
||||
if (status === 'ok') {
|
||||
return { type: 'ok', message: t('analogSignalConverter.texts.status-ok') };
|
||||
}
|
||||
// A live zero (e.g. 2-10 V) lets a value under the minimum reveal a broken wire.
|
||||
const hasLiveZero = Math.min(signalRange.value.min, signalRange.value.max) > 0;
|
||||
return {
|
||||
type: 'warning',
|
||||
message:
|
||||
status === 'below-range' && hasLiveZero
|
||||
? t('analogSignalConverter.texts.status-below-live-zero')
|
||||
: t(`analogSignalConverter.texts.status-${status}`),
|
||||
};
|
||||
}
|
||||
|
||||
function getEngineeringStatus(value: number): SideStatus {
|
||||
const status = getSignalRangeStatus({ value, range: engineeringRange.value });
|
||||
return status === 'ok'
|
||||
? { type: 'ok', message: t('analogSignalConverter.texts.status-ok') }
|
||||
: { type: 'warning', message: t(`analogSignalConverter.texts.engineering-${status}`) };
|
||||
}
|
||||
|
||||
function statusOf(side: Side): SideStatus | null {
|
||||
const value = valueOf(side);
|
||||
if (rangesError.value || !Number.isFinite(value)) {
|
||||
return null;
|
||||
}
|
||||
return side === 'signal' ? getSignalStatus(value) : getEngineeringStatus(value);
|
||||
}
|
||||
|
||||
const inputStatus = computed(() => statusOf(inputSide.value));
|
||||
const outputStatus = computed(() => statusOf(outputSide.value));
|
||||
|
||||
const formatWithUnit = (value: number, unit: string) =>
|
||||
Number.isFinite(value) ? `${formatSignalNumber(value)}${unit ? ` ${unit}` : ''}` : '';
|
||||
const withUnit = (label: string, unit: string) => (unit ? `${label} (${unit})` : label);
|
||||
|
||||
const outputText = computed(() => formatWithUnit(outputValue.value, unitOf(outputSide.value)));
|
||||
const roundedOutputText = computed(() =>
|
||||
props.integerSignal && outputSide.value === 'signal' && Number.isFinite(outputValue.value)
|
||||
? formatWithUnit(Math.round(outputValue.value), props.signalUnit)
|
||||
: '',
|
||||
);
|
||||
const { copy: copyOutput } = useCopy({ source: () => formatSignalNumber(outputValue.value) });
|
||||
|
||||
// Significant digits rather than decimals: Siemens gains such as 100 / 27648 are tiny.
|
||||
const formatCoefficient = (value: number) => String(Number(value.toPrecision(10)));
|
||||
|
||||
const formula = computed(() => {
|
||||
if (rangesError.value) {
|
||||
return '';
|
||||
}
|
||||
const { gain, offset } = getLinearTransform({ from: rangeOf(inputSide.value), to: rangeOf(outputSide.value) });
|
||||
const names = {
|
||||
signal: t('analogSignalConverter.texts.formula-signal'),
|
||||
engineering: t('analogSignalConverter.texts.formula-value'),
|
||||
};
|
||||
const product = `${names[outputSide.value]} = ${formatCoefficient(gain)} × ${names[inputSide.value]}`;
|
||||
return formatCoefficient(offset) === '0'
|
||||
? product
|
||||
: `${product} ${offset < 0 ? '-' : '+'} ${formatCoefficient(Math.abs(offset))}`;
|
||||
});
|
||||
|
||||
const referencePoints = computed(() => {
|
||||
if (rangesError.value) {
|
||||
return [];
|
||||
}
|
||||
return [0, 25, 50, 75, 100].map((percent) => {
|
||||
const signal = scaleValue({ value: percent, from: { min: 0, max: 100 }, to: signalRange.value });
|
||||
const value = scaleValue({ value: percent, from: { min: 0, max: 100 }, to: engineeringRange.value });
|
||||
return {
|
||||
percent: `${percent} %`,
|
||||
signal: formatWithUnit(props.integerSignal ? Math.round(signal) : signal, props.signalUnit),
|
||||
value: formatWithUnit(value, engineeringUnit.value),
|
||||
};
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div flex flex-col gap-3>
|
||||
<div class="converter-columns">
|
||||
<!-- Input -->
|
||||
<c-card class="column" :title="t('analogSignalConverter.texts.title-input')">
|
||||
<div class="side-label">
|
||||
{{ withUnit(labelOf(inputSide), unitOf(inputSide)) }}
|
||||
</div>
|
||||
<n-input-number-i18n v-model:value="inputValue" size="large" data-test-id="converter-input" />
|
||||
|
||||
<AnalogGauge
|
||||
v-if="!rangesError"
|
||||
:min="rangeOf(inputSide).min"
|
||||
:max="rangeOf(inputSide).max"
|
||||
:value="valueOf(inputSide)"
|
||||
:unit="unitOf(inputSide)"
|
||||
:status="inputStatus?.type"
|
||||
data-test-id="input-gauge"
|
||||
/>
|
||||
|
||||
<div v-if="inputStatus" class="status" :class="inputStatus.type" data-test-id="input-status">
|
||||
<icon-mdi-check-circle v-if="inputStatus.type === 'ok'" />
|
||||
<icon-mdi-alert v-else />
|
||||
<span>{{ inputStatus.message }}</span>
|
||||
</div>
|
||||
</c-card>
|
||||
|
||||
<!-- Parameters -->
|
||||
<c-card class="column" :title="t('analogSignalConverter.texts.title-parameters')">
|
||||
<!-- c-select keeps the label it was mounted with: remount it when the language changes -->
|
||||
<c-select
|
||||
:key="locale"
|
||||
v-model:value="selectedPreset"
|
||||
:options="presetOptions"
|
||||
:label="t('analogSignalConverter.texts.label-signal-type')"
|
||||
data-test-id="signal-preset"
|
||||
/>
|
||||
|
||||
<div class="side-label" mt-3>
|
||||
{{ withUnit(`${signalLabel} min / max`, signalUnit) }}
|
||||
</div>
|
||||
<div flex gap-2>
|
||||
<n-input-number-i18n
|
||||
v-model:value="signalMin"
|
||||
:status="isSignalRangeInvalid ? 'error' : undefined"
|
||||
flex-1
|
||||
:show-button="false"
|
||||
data-test-id="signal-min"
|
||||
/>
|
||||
<n-input-number-i18n
|
||||
v-model:value="signalMax"
|
||||
:status="isSignalRangeInvalid ? 'error' : undefined"
|
||||
flex-1
|
||||
:show-button="false"
|
||||
data-test-id="signal-max"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="swap" my-4>
|
||||
<c-button
|
||||
round
|
||||
:title="t('analogSignalConverter.texts.swap-direction')"
|
||||
data-test-id="swap-direction"
|
||||
@click="swapDirection"
|
||||
>
|
||||
<icon-mdi-swap-horizontal text-20px />
|
||||
<span ml-2>{{ t('analogSignalConverter.texts.swap-direction') }}</span>
|
||||
</c-button>
|
||||
</div>
|
||||
|
||||
<div class="side-label">
|
||||
{{ t('analogSignalConverter.texts.label-engineering-range') }}
|
||||
</div>
|
||||
<div flex gap-2>
|
||||
<n-input-number-i18n
|
||||
v-model:value="engineeringMin"
|
||||
:status="isEngineeringRangeInvalid ? 'error' : undefined"
|
||||
flex-1
|
||||
:show-button="false"
|
||||
data-test-id="engineering-min"
|
||||
/>
|
||||
<n-input-number-i18n
|
||||
v-model:value="engineeringMax"
|
||||
:status="isEngineeringRangeInvalid ? 'error' : undefined"
|
||||
flex-1
|
||||
:show-button="false"
|
||||
data-test-id="engineering-max"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<c-input-text
|
||||
v-model:value="engineeringUnit"
|
||||
:label="t('analogSignalConverter.texts.label-engineering-unit')"
|
||||
:placeholder="t('analogSignalConverter.texts.placeholder-unit')"
|
||||
mt-3
|
||||
data-test-id="engineering-unit"
|
||||
/>
|
||||
|
||||
<c-alert v-if="rangesError" type="error" mt-3>
|
||||
{{ rangesError }}
|
||||
</c-alert>
|
||||
|
||||
<input-copyable
|
||||
v-else
|
||||
:label="t('analogSignalConverter.texts.label-formula')"
|
||||
:value="formula"
|
||||
mt-3
|
||||
data-test-id="formula"
|
||||
/>
|
||||
</c-card>
|
||||
|
||||
<!-- Output -->
|
||||
<c-card class="column" :title="t('analogSignalConverter.texts.title-output')">
|
||||
<div class="side-label">
|
||||
{{ withUnit(labelOf(outputSide), unitOf(outputSide)) }}
|
||||
</div>
|
||||
<div class="output-value">
|
||||
<span data-test-id="converter-output">{{ outputText || '—' }}</span>
|
||||
<c-button
|
||||
v-if="outputText"
|
||||
variant="text"
|
||||
circle
|
||||
:title="t('analogSignalConverter.texts.copy-output')"
|
||||
@click="copyOutput()"
|
||||
>
|
||||
<icon-mdi-content-copy />
|
||||
</c-button>
|
||||
</div>
|
||||
<div v-if="roundedOutputText" class="rounded-output" data-test-id="converter-output-rounded">
|
||||
{{ t('analogSignalConverter.texts.label-rounded-signal') }} : {{ roundedOutputText }}
|
||||
</div>
|
||||
|
||||
<AnalogGauge
|
||||
v-if="!rangesError"
|
||||
:min="rangeOf(outputSide).min"
|
||||
:max="rangeOf(outputSide).max"
|
||||
:value="outputValue"
|
||||
:unit="unitOf(outputSide)"
|
||||
:status="outputStatus?.type"
|
||||
data-test-id="output-gauge"
|
||||
/>
|
||||
|
||||
<div v-if="outputStatus" class="status" :class="outputStatus.type" data-test-id="output-status">
|
||||
<icon-mdi-check-circle v-if="outputStatus.type === 'ok'" />
|
||||
<icon-mdi-alert v-else />
|
||||
<span>{{ outputStatus.message }}</span>
|
||||
</div>
|
||||
</c-card>
|
||||
</div>
|
||||
|
||||
<c-card v-if="!rangesError" :title="t('analogSignalConverter.texts.title-reference-points')">
|
||||
<n-table size="small" data-test-id="reference-points">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ t('analogSignalConverter.texts.column-percent') }}</th>
|
||||
<th>{{ signalLabel }}</th>
|
||||
<th>{{ t('analogSignalConverter.texts.label-engineering-value') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="point of referencePoints" :key="point.percent">
|
||||
<td>{{ point.percent }}</td>
|
||||
<td>{{ point.signal }}</td>
|
||||
<td>{{ point.value }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</n-table>
|
||||
</c-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="less">
|
||||
.converter-columns {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1.2fr 1fr;
|
||||
gap: 12px;
|
||||
align-items: stretch;
|
||||
|
||||
// Narrow screens: input, parameters and output stacked
|
||||
@media (max-width: 900px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.column {
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.side-label {
|
||||
font-size: 13px;
|
||||
opacity: 0.75;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.swap {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.output-value {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
min-height: 40px;
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.rounded-output {
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
opacity: 0.75;
|
||||
}
|
||||
|
||||
.status {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
line-height: 1.4;
|
||||
|
||||
svg {
|
||||
flex-shrink: 0;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
&.ok {
|
||||
color: v-bind('themeVars.successColor');
|
||||
}
|
||||
&.warning {
|
||||
color: v-bind('themeVars.warningColor');
|
||||
}
|
||||
&.error {
|
||||
color: v-bind('themeVars.errorColor');
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -5,14 +5,8 @@ import { useCopy } from '@/composable/copy';
|
||||
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
|
||||
import { translate as t } from '@/plugins/i18n.plugin';
|
||||
|
||||
import {
|
||||
EditorView,
|
||||
basicSetup,
|
||||
} from 'codemirror';
|
||||
import {
|
||||
Compartment,
|
||||
EditorState,
|
||||
} from '@codemirror/state';
|
||||
import { EditorView, basicSetup } from 'codemirror';
|
||||
import { Compartment, EditorState } from '@codemirror/state';
|
||||
|
||||
import { javascript } from '@codemirror/lang-javascript';
|
||||
import { html } from '@codemirror/lang-html';
|
||||
@@ -34,16 +28,15 @@ import { useStyleStore } from '@/stores/style.store';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
value: string
|
||||
language?: string
|
||||
copyPlacement?: 'top-right' | 'bottom-right' | 'outside' | 'none'
|
||||
copyMessage?: string
|
||||
wordWrap?: boolean
|
||||
downloadFileName?: string
|
||||
downloadButtonText?: string
|
||||
maxHeight?: string
|
||||
showLineNumbers?: boolean
|
||||
showFoldGutter?: boolean
|
||||
value: string;
|
||||
language?: string;
|
||||
copyPlacement?: 'top-right' | 'bottom-right' | 'outside' | 'none';
|
||||
copyMessage?: string;
|
||||
downloadFileName?: string;
|
||||
downloadButtonText?: string;
|
||||
maxHeight?: string;
|
||||
showLineNumbers?: boolean;
|
||||
showFoldGutter?: boolean;
|
||||
}>(),
|
||||
{
|
||||
language: 'txt',
|
||||
@@ -55,7 +48,17 @@ const props = withDefaults(
|
||||
},
|
||||
);
|
||||
|
||||
const { value, maxHeight, language, showLineNumbers, showFoldGutter, copyPlacement, copyMessage, downloadFileName, downloadButtonText } = toRefs(props);
|
||||
const {
|
||||
value,
|
||||
maxHeight,
|
||||
language,
|
||||
showLineNumbers,
|
||||
showFoldGutter,
|
||||
copyPlacement,
|
||||
copyMessage,
|
||||
downloadFileName,
|
||||
downloadButtonText,
|
||||
} = toRefs(props);
|
||||
|
||||
const styleStore = useStyleStore();
|
||||
const isDarkTheme = computed(() => styleStore.isDarkTheme);
|
||||
@@ -68,11 +71,7 @@ const themeCompartment = new Compartment();
|
||||
const languageCompartment = new Compartment();
|
||||
|
||||
const maxHeightStyle = computed(() =>
|
||||
maxHeight.value
|
||||
? typeof maxHeight.value === 'number'
|
||||
? `${maxHeight.value}px`
|
||||
: maxHeight.value
|
||||
: '400px',
|
||||
maxHeight.value ? (typeof maxHeight.value === 'number' ? `${maxHeight.value}px` : maxHeight.value) : '400px',
|
||||
);
|
||||
|
||||
// ---------------------------
|
||||
@@ -143,13 +142,12 @@ function createExtensions() {
|
||||
basicSetup,
|
||||
EditorView.editable.of(false),
|
||||
EditorState.readOnly.of(true),
|
||||
EditorView.lineWrapping,
|
||||
keymap.of(foldKeymap),
|
||||
themeCompartment.of(themeExtension()),
|
||||
languageCompartment.of(resolveLanguage(language.value ?? 'plain')),
|
||||
(showLineNumbers.value ?? true) ? lineNumbers() : [],
|
||||
(showFoldGutter.value ?? true)
|
||||
? foldGutter({ openText: '▾', closedText: '▸' })
|
||||
: [],
|
||||
(showFoldGutter.value ?? true) ? foldGutter({ openText: '▾', closedText: '▸' }) : [],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -191,52 +189,59 @@ watch(
|
||||
() => {
|
||||
if (view) {
|
||||
view.dispatch({
|
||||
effects: languageCompartment.reconfigure(
|
||||
resolveLanguage(props.language ?? 'plain'),
|
||||
),
|
||||
effects: languageCompartment.reconfigure(resolveLanguage(props.language ?? 'plain')),
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
watch(() => props.value, (newVal) => {
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
const current = view.state.doc.toString();
|
||||
if (newVal !== current) {
|
||||
view.dispatch({
|
||||
changes: {
|
||||
from: 0,
|
||||
to: view.state.doc.length,
|
||||
insert: newVal,
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
watch(
|
||||
() => props.value,
|
||||
(newVal) => {
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
const current = view.state.doc.toString();
|
||||
if (newVal !== current) {
|
||||
view.dispatch({
|
||||
changes: {
|
||||
from: 0,
|
||||
to: view.state.doc.length,
|
||||
insert: newVal,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const { copy, isJustCopied } = useCopy({ source: value, createToast: false });
|
||||
const tooltipText = computed(() => isJustCopied.value ? t('textareaCopyable.copied') : copyMessage.value);
|
||||
const tooltipText = computed(() => (isJustCopied.value ? t('textareaCopyable.copied') : copyMessage.value));
|
||||
|
||||
const valueBase64 = computed(() => Base64.encode(value.value));
|
||||
const { download } = useDownloadFileFromBase64(
|
||||
{
|
||||
source: valueBase64,
|
||||
filename: downloadFileName,
|
||||
});
|
||||
const { download } = useDownloadFileFromBase64({
|
||||
source: valueBase64,
|
||||
filename: downloadFileName,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="overflow-x: hidden; width: 100%">
|
||||
<c-card
|
||||
relative
|
||||
:style="copyPlacement === 'top-right' ? 'padding-top: 50px' : (copyPlacement === 'bottom-right' ? 'padding-bottom: 50px' : '')"
|
||||
:style="
|
||||
copyPlacement === 'top-right'
|
||||
? 'padding-top: 50px'
|
||||
: copyPlacement === 'bottom-right'
|
||||
? 'padding-bottom: 50px'
|
||||
: ''
|
||||
"
|
||||
>
|
||||
<div
|
||||
v-if="value && copyPlacement !== 'none'"
|
||||
absolute right-10px
|
||||
:class="copyPlacement === 'top-right' ? 'top-10px' : (copyPlacement === 'bottom-right' ? 'bottom-10px' : '')"
|
||||
style="z-index: 10; background: var(--bg-color); border-radius: 50%; padding: 2px;"
|
||||
absolute
|
||||
right-10px
|
||||
:class="copyPlacement === 'top-right' ? 'top-10px' : copyPlacement === 'bottom-right' ? 'bottom-10px' : ''"
|
||||
style="z-index: 10; background: var(--bg-color); border-radius: 50%; padding: 2px"
|
||||
>
|
||||
<c-tooltip v-if="value && copyPlacement !== 'outside'" :tooltip="tooltipText" position="left">
|
||||
<c-button circle important:h-10 important:w-10 @click="copy()">
|
||||
|
||||
@@ -21,8 +21,8 @@ const collapsedCategories = useStorage<Record<string, boolean>>(
|
||||
{
|
||||
deep: true,
|
||||
serializer: {
|
||||
read: v => (v ? JSON.parse(v) : null),
|
||||
write: v => JSON.stringify(v),
|
||||
read: (v) => (v ? JSON.parse(v) : null),
|
||||
write: (v) => JSON.stringify(v),
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -47,14 +47,23 @@ watchEffect(() => {
|
||||
const isToggling = ref(false);
|
||||
const menuContainerRefs = ref<Record<string, HTMLElement>>({});
|
||||
|
||||
// Every category starts coMount a category's items when it first opens, then keep themllapsed, so mounting all ~460 items up front built a
|
||||
// menu nobody can see. Mount a category's items when it first opens, then keep them.
|
||||
const openedCategories = ref<Record<string, boolean>>({});
|
||||
watchEffect(() => {
|
||||
toolsByCategory.value.forEach(({ name }) => {
|
||||
if (collapsedCategories.value[name] === false) {
|
||||
openedCategories.value[name] = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function toggleCategoryCollapse({ name }: { name: string }) {
|
||||
collapsedCategories.value[name] = !collapsedCategories.value[name];
|
||||
}
|
||||
|
||||
const areAllCollapsed = computed(() => {
|
||||
return toolsByCategory.value.every(({ name }) =>
|
||||
collapsedCategories.value[name] !== false,
|
||||
);
|
||||
return toolsByCategory.value.every(({ name }) => collapsedCategories.value[name] !== false);
|
||||
});
|
||||
|
||||
async function toggleAllCategories() {
|
||||
@@ -82,21 +91,22 @@ function getAnimationDuration(itemCount: number): number {
|
||||
const baseDuration = 250;
|
||||
const durationIncrement = 5;
|
||||
|
||||
return baseDuration + (Math.min(itemCount, 30) * durationIncrement);
|
||||
return baseDuration + Math.min(itemCount, 30) * durationIncrement;
|
||||
}
|
||||
|
||||
// Function to check if any tool in the category is active
|
||||
function isCategoryActive(components: Tool[]): boolean {
|
||||
return components.some(tool => tool.path === route.path);
|
||||
return components.some((tool) => tool.path === route.path);
|
||||
}
|
||||
|
||||
// Depends on the tool list only: holding the collapsed/active flags in here rebuilt
|
||||
// every category's `tools` array, re-rendering all ~460 items on each navigation.
|
||||
const menuOptions = computed(() =>
|
||||
toolsByCategory.value.map(({ name, components }) => ({
|
||||
name,
|
||||
isCollapsed: collapsedCategories.value[name],
|
||||
isActive: isCategoryActive(components),
|
||||
components,
|
||||
animationDuration: getAnimationDuration(components.length),
|
||||
tools: components.map(tool => ({
|
||||
tools: components.map((tool) => ({
|
||||
label: makeLabel(tool),
|
||||
icon: makeIcon(tool),
|
||||
key: tool.path,
|
||||
@@ -105,16 +115,14 @@ const menuOptions = computed(() =>
|
||||
);
|
||||
|
||||
async function scrollToActiveItem() {
|
||||
const activeCategory = toolsByCategory.value.find(({ components }) =>
|
||||
isCategoryActive(components),
|
||||
);
|
||||
const activeCategory = toolsByCategory.value.find(({ components }) => isCategoryActive(components));
|
||||
|
||||
if (activeCategory) {
|
||||
// Expand the active category
|
||||
collapsedCategories.value[activeCategory.name] = false;
|
||||
|
||||
// Wait for the entire animation to complete
|
||||
await new Promise(resolve => setTimeout(resolve, getAnimationDuration(activeCategory.components.length) + 50));
|
||||
await new Promise((resolve) => setTimeout(resolve, getAnimationDuration(activeCategory.components.length) + 50));
|
||||
|
||||
// Scroll to the active menu item
|
||||
const menuContainer = menuContainerRefs.value[activeCategory.name];
|
||||
@@ -131,9 +139,12 @@ onMounted(() => {
|
||||
scrollToActiveItem();
|
||||
});
|
||||
|
||||
watch(() => route.path, () => {
|
||||
scrollToActiveItem();
|
||||
});
|
||||
watch(
|
||||
() => route.path,
|
||||
() => {
|
||||
scrollToActiveItem();
|
||||
},
|
||||
);
|
||||
|
||||
const themeVars = useThemeVars();
|
||||
</script>
|
||||
@@ -147,19 +158,33 @@ const themeVars = useThemeVars();
|
||||
{{ areAllCollapsed ? $t('collapsibleToolMenu.text.expanding') : $t('collapsibleToolMenu.text.collapsing') }}
|
||||
</span>
|
||||
<span v-else>
|
||||
{{ areAllCollapsed ? $t('collapsibleToolMenu.text.expand-all-tools') : $t('collapsibleToolMenu.text.collapse-all-tools') }}
|
||||
{{
|
||||
areAllCollapsed
|
||||
? $t('collapsibleToolMenu.text.expand-all-tools')
|
||||
: $t('collapsibleToolMenu.text.collapse-all-tools')
|
||||
}}
|
||||
</span>
|
||||
</c-button>
|
||||
</div>
|
||||
|
||||
<div v-for="{ name, tools, isCollapsed, isActive, animationDuration } of menuOptions" :key="name" class="category-container">
|
||||
<div v-for="{ name, components, tools, animationDuration } of menuOptions" :key="name" class="category-container">
|
||||
<button
|
||||
class="category-button"
|
||||
:class="{ 'category-active': isActive }"
|
||||
flex cursor-pointer items-center op-60
|
||||
:class="{ 'category-active': isCategoryActive(components) }"
|
||||
flex
|
||||
cursor-pointer
|
||||
items-center
|
||||
op-60
|
||||
@click="toggleCategoryCollapse({ name })"
|
||||
>
|
||||
<span :class="{ 'rotate-0': isCollapsed, 'rotate-90': !isCollapsed }" text-16px lh-1 op-50 transition-transform duration-200>
|
||||
<span
|
||||
:class="{ 'rotate-0': collapsedCategories[name], 'rotate-90': !collapsedCategories[name] }"
|
||||
text-16px
|
||||
lh-1
|
||||
op-50
|
||||
transition-transform
|
||||
duration-200
|
||||
>
|
||||
<icon-mdi-chevron-right />
|
||||
</span>
|
||||
|
||||
@@ -169,15 +194,20 @@ const themeVars = useThemeVars();
|
||||
</button>
|
||||
|
||||
<div
|
||||
:ref="el => { if (el) menuContainerRefs[name] = el as HTMLElement }"
|
||||
:ref="
|
||||
(el) => {
|
||||
if (el) menuContainerRefs[name] = el as HTMLElement;
|
||||
}
|
||||
"
|
||||
class="menu-container"
|
||||
:class="{ collapsed: isCollapsed }"
|
||||
:class="{ collapsed: collapsedCategories[name] }"
|
||||
:style="{ '--animation-duration': `${animationDuration}ms` }"
|
||||
>
|
||||
<div class="menu-wrapper">
|
||||
<div class="toggle-bar" @click="toggleCategoryCollapse({ name })" />
|
||||
|
||||
<n-menu
|
||||
v-if="openedCategories[name]"
|
||||
class="menu"
|
||||
:value="route.path"
|
||||
:collapsed-width="64"
|
||||
@@ -227,11 +257,11 @@ const themeVars = useThemeVars();
|
||||
content-visibility: auto;
|
||||
contain-intrinsic-size: auto 36px;
|
||||
|
||||
.menu-container {
|
||||
display: grid;
|
||||
grid-template-rows: 1fr;
|
||||
transition: grid-template-rows var(--animation-duration, 250ms) ease-out;
|
||||
will-change: grid-template-rows;
|
||||
.menu-container {
|
||||
display: grid;
|
||||
grid-template-rows: 1fr;
|
||||
transition: grid-template-rows var(--animation-duration, 250ms) ease-out;
|
||||
will-change: grid-template-rows;
|
||||
|
||||
&.collapsed {
|
||||
grid-template-rows: 0fr;
|
||||
|
||||
@@ -24,7 +24,7 @@ function toggleFavorite(event: MouseEvent) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<c-tooltip :tooltip="isFavorite ? $t('favoriteButton.remove') : $t('favoriteButton.add') ">
|
||||
<c-tooltip :tooltip="isFavorite ? $t('favoriteButton.remove') : $t('favoriteButton.add')">
|
||||
<c-button
|
||||
variant="text"
|
||||
circle
|
||||
|
||||
@@ -9,19 +9,19 @@ import { useAppTheme } from '@/ui/theme/themes';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
transformer?: (v: string) => string
|
||||
inputValidationRules?: UseValidationRule<string>[]
|
||||
inputLabel?: string
|
||||
inputPlaceholder?: string
|
||||
inputDefault?: string
|
||||
outputLabel?: string
|
||||
outputLanguage?: string
|
||||
downloadFileName?: string
|
||||
downloadButtonText?: string
|
||||
rows?: number
|
||||
inputLineNumbers?: boolean
|
||||
inputMaxRows?: number
|
||||
inputAutosize?: boolean
|
||||
transformer?: (v: string) => string;
|
||||
inputValidationRules?: UseValidationRule<string>[];
|
||||
inputLabel?: string;
|
||||
inputPlaceholder?: string;
|
||||
inputDefault?: string;
|
||||
outputLabel?: string;
|
||||
outputLanguage?: string;
|
||||
downloadFileName?: string;
|
||||
downloadButtonText?: string;
|
||||
rows?: number;
|
||||
inputLineNumbers?: boolean;
|
||||
inputMaxRows?: number;
|
||||
inputAutosize?: boolean;
|
||||
}>(),
|
||||
{
|
||||
transformer: _.identity,
|
||||
@@ -41,8 +41,19 @@ const props = withDefaults(
|
||||
);
|
||||
|
||||
const {
|
||||
transformer, inputValidationRules, inputLabel, outputLabel, outputLanguage,
|
||||
inputPlaceholder, inputDefault, downloadFileName, downloadButtonText, rows, inputLineNumbers, inputMaxRows, inputAutosize,
|
||||
transformer,
|
||||
inputValidationRules,
|
||||
inputLabel,
|
||||
outputLabel,
|
||||
outputLanguage,
|
||||
inputPlaceholder,
|
||||
inputDefault,
|
||||
downloadFileName,
|
||||
downloadButtonText,
|
||||
rows,
|
||||
inputLineNumbers,
|
||||
inputMaxRows,
|
||||
inputAutosize,
|
||||
} = toRefs(props);
|
||||
|
||||
const appTheme = useAppTheme();
|
||||
@@ -140,12 +151,13 @@ watch(
|
||||
|
||||
watch(
|
||||
input,
|
||||
() => nextTick(() => {
|
||||
const textarea = textareaElement.value;
|
||||
if (textarea) {
|
||||
lineNumbersOffset.value = textarea.scrollTop;
|
||||
}
|
||||
}),
|
||||
() =>
|
||||
nextTick(() => {
|
||||
const textarea = textareaElement.value;
|
||||
if (textarea) {
|
||||
lineNumbersOffset.value = textarea.scrollTop;
|
||||
}
|
||||
}),
|
||||
{ flush: 'post' },
|
||||
);
|
||||
|
||||
@@ -154,11 +166,10 @@ function focusInput() {
|
||||
}
|
||||
|
||||
const outputBase64 = computed(() => Base64.encode(output.value));
|
||||
const { download } = useDownloadFileFromBase64(
|
||||
{
|
||||
source: outputBase64,
|
||||
filename: downloadFileName,
|
||||
});
|
||||
const { download } = useDownloadFileFromBase64({
|
||||
source: outputBase64,
|
||||
filename: downloadFileName,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -191,7 +202,9 @@ const { download } = useDownloadFileFromBase64(
|
||||
aria-hidden="true"
|
||||
@click="focusInput"
|
||||
>
|
||||
<pre class="line-numbers__content" :style="{ transform: `translateY(-${lineNumbersOffset}px)` }">{{ lineNumbersText }}</pre>
|
||||
<pre class="line-numbers__content" :style="{ transform: `translateY(-${lineNumbersOffset}px)` }">{{
|
||||
lineNumbersText
|
||||
}}</pre>
|
||||
</div>
|
||||
</template>
|
||||
</CInputText>
|
||||
@@ -199,7 +212,11 @@ const { download } = useDownloadFileFromBase64(
|
||||
<div overflow-auto>
|
||||
<n-tabs type="line">
|
||||
<n-tab-pane name="output" :tab="outputLabel">
|
||||
<textarea-copyable :value="output" :language="outputLanguage" :follow-height-of="inputElement?.inputWrapperRef" />
|
||||
<textarea-copyable
|
||||
:value="output"
|
||||
:language="outputLanguage"
|
||||
:follow-height-of="inputElement?.inputWrapperRef"
|
||||
/>
|
||||
</n-tab-pane>
|
||||
<n-tab-pane name="editable" :tab="t('formatTransformer.viewer')">
|
||||
<CodeBlockCopyable :value="output" :language="outputLanguage" />
|
||||
|
||||
@@ -4,32 +4,24 @@ import { nextTick, onMounted, onUnmounted, ref } from 'vue';
|
||||
import type { Tool } from '@/tools/tools.types';
|
||||
|
||||
defineProps<{
|
||||
tool: Tool
|
||||
tool: Tool;
|
||||
}>();
|
||||
|
||||
const textRef = ref<HTMLElement>();
|
||||
const showTooltip = ref(false);
|
||||
let resizeTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
// Must settle before the pointer arrives: n-tooltip reads `disabled` on enter,
|
||||
// so deciding on hover would leave the first hover with a stale value.
|
||||
async function checkTruncation() {
|
||||
await nextTick();
|
||||
if (textRef.value) {
|
||||
const text = textRef.value.textContent || '';
|
||||
const computedStyle = window.getComputedStyle(textRef.value);
|
||||
|
||||
// Create canvas context for precise text measurement
|
||||
const canvas = document.createElement('canvas');
|
||||
const context = canvas.getContext('2d')!;
|
||||
context.font = `${computedStyle.fontWeight} ${computedStyle.fontSize} ${computedStyle.fontFamily}`;
|
||||
const el = textRef.value;
|
||||
|
||||
const textWidth = context.measureText(text).width;
|
||||
|
||||
// Calculate precise container width by accounting for padding
|
||||
const containerWidth = textRef.value.clientWidth
|
||||
- Number.parseFloat(computedStyle.paddingLeft)
|
||||
- Number.parseFloat(computedStyle.paddingRight);
|
||||
|
||||
showTooltip.value = textWidth > containerWidth;
|
||||
if (el) {
|
||||
// .menu-text is one nowrap ellipsised line, so overflow is exactly the condition.
|
||||
// Replaces a canvas measureText() that cost a <canvas> + getComputedStyle per item.
|
||||
showTooltip.value = el.scrollWidth > el.clientWidth;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,19 +47,10 @@ onUnmounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<n-tooltip
|
||||
placement="right"
|
||||
:delay="500"
|
||||
:show-arrow="true"
|
||||
:disabled="!showTooltip"
|
||||
>
|
||||
<n-tooltip placement="right" :delay="500" :show-arrow="true" :disabled="!showTooltip">
|
||||
<template #trigger>
|
||||
<RouterLink :to="tool.path" class="menu-link">
|
||||
<span
|
||||
ref="textRef"
|
||||
class="menu-text"
|
||||
@mouseenter="checkTruncation"
|
||||
>
|
||||
<span ref="textRef" class="menu-text" @mouseenter="checkTruncation">
|
||||
{{ tool.name }}
|
||||
</span>
|
||||
</RouterLink>
|
||||
|
||||
@@ -48,11 +48,14 @@ watchEffect(() => {
|
||||
// Close the menu when navigating (tool links, the about button, ...) so the
|
||||
// destination page is visible.
|
||||
const route = useRoute();
|
||||
watch(() => route.path, () => {
|
||||
if (isSmallScreen.value) {
|
||||
isMenuCollapsed.value = true;
|
||||
}
|
||||
});
|
||||
watch(
|
||||
() => route.path,
|
||||
() => {
|
||||
if (isSmallScreen.value) {
|
||||
isMenuCollapsed.value = true;
|
||||
}
|
||||
},
|
||||
);
|
||||
onUnmounted(() => {
|
||||
document.body.style.overflow = '';
|
||||
});
|
||||
@@ -93,6 +96,14 @@ const siderContentWidthPx = computed(() => `${siderContentWidth.value}px`);
|
||||
|
||||
.content {
|
||||
// background-color: #f1f5f9;
|
||||
|
||||
// Flex items default to min-width: auto, so a child wider than the viewport
|
||||
// (e.g. a long, non-wrapping line in a code viewer) stretches this whole
|
||||
// column past the screen instead of letting the child's own scroll container
|
||||
// (n-scrollbar / CodeMirror) scroll horizontally. min-width: 0 lets the
|
||||
// column shrink to the available width so that inner scrolling kicks in.
|
||||
min-width: 0;
|
||||
|
||||
::v-deep(.n-layout-scroll-container) {
|
||||
padding: 26px;
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
for (const viewport of [
|
||||
{ width: 320, height: 568 },
|
||||
{ width: 667, height: 375 },
|
||||
{ width: 1280, height: 720 },
|
||||
]) {
|
||||
test.describe(`Language menu at ${viewport.width}x${viewport.height}`, () => {
|
||||
test.use({ viewport });
|
||||
|
||||
test('scrolls to the last language without scrolling the page or dismissing the menu', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
|
||||
if (viewport.width <= 700) {
|
||||
await page.getByRole('button', { name: 'Toggle menu', exact: true }).click();
|
||||
}
|
||||
|
||||
await page.getByRole('button', { name: 'Language', exact: true }).click();
|
||||
|
||||
const menu = page.locator('.n-dropdown-menu');
|
||||
await expect(menu).toBeVisible();
|
||||
await menu.evaluate(async (element) => {
|
||||
await Promise.all(element.getAnimations().map((animation) => animation.finished));
|
||||
});
|
||||
const bounds = await menu.boundingBox();
|
||||
expect(bounds).not.toBeNull();
|
||||
expect(bounds!.y).toBeGreaterThanOrEqual(0);
|
||||
expect(bounds!.y + bounds!.height).toBeLessThanOrEqual(viewport.height);
|
||||
|
||||
const pageScroll = await page.evaluate(() => window.scrollY);
|
||||
// Move directly: locator.hover() may scroll the page to align a teleported menu.
|
||||
await page.mouse.move(bounds!.x + bounds!.width / 2, bounds!.y + bounds!.height / 2);
|
||||
const lastLanguage = menu.getByText('繁體中文', { exact: true });
|
||||
await expect(async () => {
|
||||
await page.mouse.wheel(0, 300);
|
||||
await expect(lastLanguage).toBeInViewport({ ratio: 1, timeout: 500 });
|
||||
}).toPass({ timeout: 10_000 });
|
||||
await expect(menu).toBeVisible();
|
||||
expect(await page.evaluate(() => window.scrollY)).toBe(pageScroll);
|
||||
|
||||
// A second gesture at the boundary must not chain to the page either.
|
||||
await page.mouse.wheel(0, 500);
|
||||
await page.evaluate(
|
||||
() => new Promise<void>((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve()))),
|
||||
);
|
||||
await expect(menu).toBeVisible();
|
||||
expect(await page.evaluate(() => window.scrollY)).toBe(pageScroll);
|
||||
await lastLanguage.click();
|
||||
await expect(menu).not.toBeVisible();
|
||||
await expect(page.getByRole('button', { name: '語言', exact: true })).toBeVisible();
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -35,6 +35,7 @@ const localesLong: Record<string, string> = {
|
||||
uk: 'Українська',
|
||||
ko: '한국인',
|
||||
zh: '中文',
|
||||
'zh-TW': '繁體中文',
|
||||
vi: 'Tiếng Việt',
|
||||
ar: 'عربي',
|
||||
hi: 'हिन्दी',
|
||||
@@ -60,6 +61,23 @@ function onLanguageSelect(key: string) {
|
||||
locale.value = key;
|
||||
}
|
||||
|
||||
// Keep wheel gestures inside the menu even in engines without overscroll-behavior.
|
||||
function containLanguageMenuScroll(event: WheelEvent) {
|
||||
if (event.ctrlKey) {
|
||||
return;
|
||||
}
|
||||
const scroller = (event.currentTarget as HTMLElement).querySelector('.n-scrollbar-container');
|
||||
if (!scroller) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
(event.deltaY < 0 && scroller.scrollTop <= 0) ||
|
||||
(event.deltaY > 0 && scroller.scrollTop + scroller.clientHeight >= scroller.scrollHeight - 1)
|
||||
) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
const themeOptions = computed(() => [
|
||||
{
|
||||
key: 'auto',
|
||||
@@ -119,13 +137,33 @@ function closeMenuOnSmallScreen() {
|
||||
</c-button>
|
||||
</n-dropdown>
|
||||
|
||||
<n-dropdown :options="languageOptions" trigger="click" @select="onLanguageSelect">
|
||||
<n-dropdown
|
||||
class="language-dropdown"
|
||||
:options="languageOptions"
|
||||
trigger="click"
|
||||
scrollable
|
||||
@select="onLanguageSelect"
|
||||
@wheel="containLanguageMenuScroll"
|
||||
>
|
||||
<c-button circle variant="text" :aria-label="t('home.nav.language', 'Language')">
|
||||
<n-icon size="25" :component="IconLanguage" />
|
||||
</c-button>
|
||||
</n-dropdown>
|
||||
</template>
|
||||
|
||||
<style lang="less">
|
||||
// The menu is teleported outside this component. Keep it within the viewport,
|
||||
// with room for its trigger whether the popover opens above or below it.
|
||||
.language-dropdown {
|
||||
max-height: min(400px, calc(50vh - 24px));
|
||||
max-height: min(400px, calc(50dvh - 24px));
|
||||
|
||||
.n-scrollbar-container {
|
||||
overscroll-behavior-y: contain;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.n-button {
|
||||
&:not(:last-child) {
|
||||
|
||||
@@ -8,7 +8,7 @@ const { value } = toRefs(props);
|
||||
const initialText = t('spanCopyable.copy');
|
||||
|
||||
const { copy, isJustCopied } = useCopy({ source: value, createToast: false });
|
||||
const tooltipText = computed(() => isJustCopied.value ? t('spanCopyable.copied') : initialText);
|
||||
const tooltipText = computed(() => (isJustCopied.value ? t('spanCopyable.copied') : initialText));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -24,16 +24,16 @@ import { translate as t } from '@/plugins/i18n.plugin';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
value: string
|
||||
followHeightOf?: HTMLElement | null
|
||||
language?: string
|
||||
copyPlacement?: 'top-right' | 'bottom-right' | 'outside' | 'none'
|
||||
copyMessage?: string
|
||||
wordWrap?: boolean
|
||||
downloadFileName?: string
|
||||
downloadButtonText?: string
|
||||
scrollable?: boolean
|
||||
maxHeight?: string
|
||||
value: string;
|
||||
followHeightOf?: HTMLElement | null;
|
||||
language?: string;
|
||||
copyPlacement?: 'top-right' | 'bottom-right' | 'outside' | 'none';
|
||||
copyMessage?: string;
|
||||
wordWrap?: boolean;
|
||||
downloadFileName?: string;
|
||||
downloadButtonText?: string;
|
||||
scrollable?: boolean;
|
||||
maxHeight?: string;
|
||||
}>(),
|
||||
{
|
||||
followHeightOf: null,
|
||||
@@ -65,36 +65,46 @@ hljs.registerLanguage('python', pythonHljs);
|
||||
hljs.registerLanguage('php', phpHljs);
|
||||
hljs.registerLanguage('protobuf', protobufHljs);
|
||||
|
||||
const { value, language, followHeightOf, copyPlacement, copyMessage, downloadFileName, downloadButtonText } = toRefs(props);
|
||||
const { value, language, followHeightOf, copyPlacement, copyMessage, downloadFileName, downloadButtonText } =
|
||||
toRefs(props);
|
||||
const { height } = followHeightOf.value ? useElementSize(followHeightOf) : { height: ref(null) };
|
||||
|
||||
const scrollbarRef = ref();
|
||||
|
||||
// Watch for content changes and scroll to bottom
|
||||
watch(value, () => {
|
||||
nextTick(() => {
|
||||
if (scrollbarRef.value) {
|
||||
scrollbarRef.value.scrollTo({ top: scrollbarRef.value.scrollbarInstRef.containerRef.scrollHeight });
|
||||
}
|
||||
});
|
||||
}, { flush: 'post' });
|
||||
watch(
|
||||
value,
|
||||
() => {
|
||||
nextTick(() => {
|
||||
if (scrollbarRef.value) {
|
||||
scrollbarRef.value.scrollTo({ top: scrollbarRef.value.scrollbarInstRef.containerRef.scrollHeight });
|
||||
}
|
||||
});
|
||||
},
|
||||
{ flush: 'post' },
|
||||
);
|
||||
|
||||
const { copy, isJustCopied } = useCopy({ source: value, createToast: false });
|
||||
const tooltipText = computed(() => isJustCopied.value ? t('textareaCopyable.copied') : copyMessage.value);
|
||||
const tooltipText = computed(() => (isJustCopied.value ? t('textareaCopyable.copied') : copyMessage.value));
|
||||
|
||||
const valueBase64 = computed(() => Base64.encode(value.value));
|
||||
const { download } = useDownloadFileFromBase64(
|
||||
{
|
||||
source: valueBase64,
|
||||
filename: downloadFileName,
|
||||
});
|
||||
const { download } = useDownloadFileFromBase64({
|
||||
source: valueBase64,
|
||||
filename: downloadFileName,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="overflow-x: hidden; width: 100%">
|
||||
<c-card
|
||||
relative
|
||||
:style="copyPlacement === 'top-right' ? 'padding-top: 50px' : (copyPlacement === 'bottom-right' ? 'padding-bottom: 50px' : '')"
|
||||
:style="
|
||||
copyPlacement === 'top-right'
|
||||
? 'padding-top: 50px'
|
||||
: copyPlacement === 'bottom-right'
|
||||
? 'padding-bottom: 50px'
|
||||
: ''
|
||||
"
|
||||
>
|
||||
<n-scrollbar
|
||||
ref="scrollbarRef"
|
||||
@@ -112,8 +122,9 @@ const { download } = useDownloadFileFromBase64(
|
||||
</n-scrollbar>
|
||||
<div
|
||||
v-if="value && copyPlacement !== 'none'"
|
||||
absolute right-10px
|
||||
:class="copyPlacement === 'top-right' ? 'top-10px' : (copyPlacement === 'bottom-right' ? 'bottom-10px' : '')"
|
||||
absolute
|
||||
right-10px
|
||||
:class="copyPlacement === 'top-right' ? 'top-10px' : copyPlacement === 'bottom-right' ? 'bottom-10px' : ''"
|
||||
:style="scrollable ? 'z-index: 10; background: var(--bg-color); border-radius: 50%; padding: 2px;' : ''"
|
||||
>
|
||||
<c-tooltip v-if="value && copyPlacement !== 'outside'" :tooltip="tooltipText" position="left">
|
||||
|
||||
@@ -32,10 +32,7 @@ const theme = useThemeVars();
|
||||
|
||||
<div class="truncat my-5px text-lg text-black dark:text-white">
|
||||
{{ tool.name }}
|
||||
<World
|
||||
v-if="tool.externAccessDescription"
|
||||
class="tool-privacy-icon"
|
||||
/>
|
||||
<World v-if="tool.externAccessDescription" class="tool-privacy-icon" />
|
||||
</div>
|
||||
|
||||
<div class="line-clamp-2 text-neutral-500 dark:text-neutral-400">
|
||||
@@ -48,6 +45,6 @@ const theme = useThemeVars();
|
||||
<style lang="css" scoped>
|
||||
.tool-privacy-icon {
|
||||
display: inline-block;
|
||||
height: .9em;
|
||||
height: 0.9em;
|
||||
}
|
||||
</style>
|
||||
@@ -4,7 +4,7 @@ import * as unitsconverter from 'units-converter';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
supportedUnits: { [key: string]: string };
|
||||
supportedUnits: { [key: string]: { value: string; label: string } };
|
||||
defaultUnit: string;
|
||||
labelWidth?: string;
|
||||
unitMinWidth?: string;
|
||||
@@ -47,10 +47,11 @@ const SI_PREFIX_NAMES = [
|
||||
|
||||
const SI_PREFIX_NAMES_REGEX = new RegExp(`^(${SI_PREFIX_NAMES.join('|')})`);
|
||||
|
||||
const units = reactive<Record<string, { title: string; unit: string; ref: number }>>(
|
||||
const units = reactive<Record<string, { local_title: string; eng_title: string; unit: string; ref: number }>>(
|
||||
Object.entries(supportedUnits.value)
|
||||
.map(([key, label]) => ({
|
||||
title: label,
|
||||
.map(([key, { label, value }]) => ({
|
||||
eng_title: value,
|
||||
local_title: label,
|
||||
unit: key,
|
||||
ref: 1,
|
||||
}))
|
||||
@@ -69,7 +70,7 @@ const filteredUnits = computed(() => {
|
||||
return Object.entries(units);
|
||||
}
|
||||
|
||||
return Object.entries(units).filter(([_, { title }]) => !SI_PREFIX_NAMES_REGEX.test(title));
|
||||
return Object.entries(units).filter(([_, { eng_title }]) => !SI_PREFIX_NAMES_REGEX.test(eng_title));
|
||||
});
|
||||
|
||||
function update(key: string) {
|
||||
@@ -125,9 +126,9 @@ update(defaultUnit.value);
|
||||
{{ $t('tools.UnitsConverter.text.si-converter') }}
|
||||
</c-link>
|
||||
</n-space>
|
||||
<n-input-group v-for="[key, { title, unit }] in filteredUnits" :key="key" mb-3 w-full>
|
||||
<n-input-group-label :style="{ width: labelWidth }">
|
||||
{{ title }}
|
||||
<n-input-group v-for="[key, { local_title, unit }] in filteredUnits" :key="key" mb-3 w-full>
|
||||
<n-input-group-label :style="{ minWidth: labelWidth }">
|
||||
{{ local_title }}
|
||||
</n-input-group-label>
|
||||
|
||||
<n-input-number v-model:value="units[key].ref" style="flex: 1" @update:value="() => update(key)" />
|
||||
|
||||
@@ -2,8 +2,14 @@ import { type Ref, ref, watchEffect } from 'vue';
|
||||
|
||||
export { computedCatch, computedCatchAsync };
|
||||
|
||||
function computedCatch<T, D>(getter: () => T, { defaultValue }: { defaultValue: D; defaultErrorMessage?: string }): [Ref<T | D>, Ref<string | undefined>];
|
||||
function computedCatch<T, D>(getter: () => T, { defaultValue, defaultErrorMessage = 'Unknown error' }: { defaultValue?: D; defaultErrorMessage?: string } = {}) {
|
||||
function computedCatch<T, D>(
|
||||
getter: () => T,
|
||||
{ defaultValue }: { defaultValue: D; defaultErrorMessage?: string },
|
||||
): [Ref<T | D>, Ref<string | undefined>];
|
||||
function computedCatch<T, D>(
|
||||
getter: () => T,
|
||||
{ defaultValue, defaultErrorMessage = 'Unknown error' }: { defaultValue?: D; defaultErrorMessage?: string } = {},
|
||||
) {
|
||||
const error = ref<string | undefined>();
|
||||
const value = ref<T | D | undefined>();
|
||||
|
||||
@@ -11,9 +17,8 @@ function computedCatch<T, D>(getter: () => T, { defaultValue, defaultErrorMessag
|
||||
try {
|
||||
error.value = undefined;
|
||||
value.value = getter();
|
||||
}
|
||||
catch (err) {
|
||||
error.value = err instanceof Error ? err.message : err?.toString() ?? defaultErrorMessage;
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err.message : (err?.toString() ?? defaultErrorMessage);
|
||||
value.value = defaultValue;
|
||||
}
|
||||
});
|
||||
@@ -21,8 +26,14 @@ function computedCatch<T, D>(getter: () => T, { defaultValue, defaultErrorMessag
|
||||
return [value, error] as const;
|
||||
}
|
||||
|
||||
function computedCatchAsync<T, D>(getterAsync: () => Promise<T>, { defaultValue }: { defaultValue: D; defaultErrorMessage?: string }): [Ref<T | D>, Ref<string | undefined>];
|
||||
function computedCatchAsync<T, D>(getterAsync: () => Promise<T>, { defaultValue, defaultErrorMessage = 'Unknown error' }: { defaultValue?: D; defaultErrorMessage?: string } = {}) {
|
||||
function computedCatchAsync<T, D>(
|
||||
getterAsync: () => Promise<T>,
|
||||
{ defaultValue }: { defaultValue: D; defaultErrorMessage?: string },
|
||||
): [Ref<T | D>, Ref<string | undefined>];
|
||||
function computedCatchAsync<T, D>(
|
||||
getterAsync: () => Promise<T>,
|
||||
{ defaultValue, defaultErrorMessage = 'Unknown error' }: { defaultValue?: D; defaultErrorMessage?: string } = {},
|
||||
) {
|
||||
const error = ref<string | undefined>();
|
||||
const value = ref<T | D | undefined>();
|
||||
|
||||
@@ -30,9 +41,8 @@ function computedCatchAsync<T, D>(getterAsync: () => Promise<T>, { defaultValue,
|
||||
try {
|
||||
error.value = undefined;
|
||||
value.value = await getterAsync();
|
||||
}
|
||||
catch (err) {
|
||||
error.value = err instanceof Error ? err.message : err?.toString() ?? defaultErrorMessage;
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err.message : (err?.toString() ?? defaultErrorMessage);
|
||||
value.value = defaultValue;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -11,8 +11,7 @@ function computedRefreshable<T>(getter: () => T, { throttle }: { throttle?: numb
|
||||
|
||||
if (throttle) {
|
||||
watchThrottled(getter, update, { throttle });
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
watch(getter, update);
|
||||
}
|
||||
|
||||
|
||||
+33
-20
@@ -4,7 +4,11 @@ import { useMessage } from 'naive-ui';
|
||||
import type { MaybeRefOrGetter } from 'vue';
|
||||
import { translate as t } from '@/plugins/i18n.plugin';
|
||||
|
||||
export function useCopy({ source, text = t('tools.copy.text.copied-to-the-clipboard'), createToast = true }: { source?: MaybeRefOrGetter<string>; text?: string; createToast?: boolean } = {}) {
|
||||
export function useCopy({
|
||||
source,
|
||||
text = t('tools.copy.text.copied-to-the-clipboard'),
|
||||
createToast = true,
|
||||
}: { source?: MaybeRefOrGetter<string>; text?: string; createToast?: boolean } = {}) {
|
||||
const { copy, copied, ...rest } = useClipboard({
|
||||
source,
|
||||
legacy: true,
|
||||
@@ -18,8 +22,7 @@ export function useCopy({ source, text = t('tools.copy.text.copied-to-the-clipbo
|
||||
async copy(content?: string, { notificationMessage }: { notificationMessage?: string } = {}) {
|
||||
if (source) {
|
||||
await copy();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
await copy(content);
|
||||
}
|
||||
|
||||
@@ -30,7 +33,11 @@ export function useCopy({ source, text = t('tools.copy.text.copied-to-the-clipbo
|
||||
};
|
||||
}
|
||||
|
||||
export function useCopyClipboardItems({ source, text = t('tools.copy.text.copied-to-the-clipboard'), createToast = true }: { source?: MaybeRefOrGetter<Array<{ mime: string; content: string }>>; text?: string; createToast?: boolean } = {}) {
|
||||
export function useCopyClipboardItems({
|
||||
source,
|
||||
text = t('tools.copy.text.copied-to-the-clipboard'),
|
||||
createToast = true,
|
||||
}: { source?: MaybeRefOrGetter<Array<{ mime: string; content: string }>>; text?: string; createToast?: boolean } = {}) {
|
||||
function toClipboardItem(item: { mime: string; content: string }) {
|
||||
return new ClipboardItem({
|
||||
[item.mime]: new Blob([item.content], { type: item.mime }),
|
||||
@@ -46,11 +53,13 @@ export function useCopyClipboardItems({ source, text = t('tools.copy.text.copied
|
||||
return {
|
||||
...rest,
|
||||
isJustCopied: copied,
|
||||
async copy(content?: { mime: string; content: string }[], { notificationMessage }: { notificationMessage?: string } = {}) {
|
||||
async copy(
|
||||
content?: { mime: string; content: string }[],
|
||||
{ notificationMessage }: { notificationMessage?: string } = {},
|
||||
) {
|
||||
if (source) {
|
||||
await copy();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
await copy((content || []).map(toClipboardItem));
|
||||
}
|
||||
|
||||
@@ -61,7 +70,17 @@ export function useCopyClipboardItems({ source, text = t('tools.copy.text.copied
|
||||
};
|
||||
}
|
||||
|
||||
export function useCopyHtml({ sourceHtml, fallbackText, toastText = t('tools.copy.text.copied-to-the-clipboard'), createToast = true }: { sourceHtml?: MaybeRefOrGetter<string>; fallbackText?: MaybeRefOrGetter<string>; toastText?: string; createToast?: boolean } = {}) {
|
||||
export function useCopyHtml({
|
||||
sourceHtml,
|
||||
fallbackText,
|
||||
toastText = t('tools.copy.text.copied-to-the-clipboard'),
|
||||
createToast = true,
|
||||
}: {
|
||||
sourceHtml?: MaybeRefOrGetter<string>;
|
||||
fallbackText?: MaybeRefOrGetter<string>;
|
||||
toastText?: string;
|
||||
createToast?: boolean;
|
||||
} = {}) {
|
||||
const message = useMessage();
|
||||
|
||||
const copied = ref(false);
|
||||
@@ -81,8 +100,7 @@ export function useCopyHtml({ sourceHtml, fallbackText, toastText = t('tools.cop
|
||||
|
||||
try {
|
||||
document.execCommand('copy');
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
}
|
||||
@@ -100,19 +118,16 @@ export function useCopyHtml({ sourceHtml, fallbackText, toastText = t('tools.cop
|
||||
const blobText = new Blob([fallbackText || html], { type: 'text/plain' });
|
||||
const item = new ClipboardItemCtor({ 'text/plain': blobText, 'text/html': blobHtml });
|
||||
await navigator.clipboard.write([item]);
|
||||
}
|
||||
else if (navigator.clipboard?.writeText) {
|
||||
} else if (navigator.clipboard?.writeText) {
|
||||
// Async text fallback
|
||||
await navigator.clipboard.writeText(fallbackText || html);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Legacy execCommand fallback
|
||||
legacyCopy(fallbackText || html);
|
||||
}
|
||||
|
||||
copied.value = true;
|
||||
}
|
||||
catch (e: any) {
|
||||
} catch (e: any) {
|
||||
error.value = e.toString();
|
||||
}
|
||||
}
|
||||
@@ -122,16 +137,14 @@ export function useCopyHtml({ sourceHtml, fallbackText, toastText = t('tools.cop
|
||||
async copy(html?: string, text?: string, { notificationMessage }: { notificationMessage?: string } = {}) {
|
||||
if (sourceHtml) {
|
||||
await copyHtml(toValue(sourceHtml), toValue(fallbackText));
|
||||
}
|
||||
else if (html) {
|
||||
} else if (html) {
|
||||
await copyHtml(html, text);
|
||||
}
|
||||
|
||||
if (createToast) {
|
||||
if (error.value) {
|
||||
message.error(error.value);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
message.success(notificationMessage ?? toastText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,21 @@ import { getMimeTypeFromBase64 } from './downloadBase64';
|
||||
describe('downloadBase64', () => {
|
||||
describe('getMimeTypeFromBase64', () => {
|
||||
it('when the base64 string has a data URI, it returns the mime type', () => {
|
||||
expect(getMimeTypeFromBase64({ base64String: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA' })).to.deep.equal({ mimeType: 'image/png' });
|
||||
expect(getMimeTypeFromBase64({ base64String: 'data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA' })).to.deep.equal({ mimeType: 'image/jpg' });
|
||||
expect(
|
||||
getMimeTypeFromBase64({ base64String: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA' }),
|
||||
).to.deep.equal({ mimeType: 'image/png' });
|
||||
expect(
|
||||
getMimeTypeFromBase64({ base64String: 'data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA' }),
|
||||
).to.deep.equal({ mimeType: 'image/jpg' });
|
||||
});
|
||||
|
||||
it('when the base64 string has no data URI, it try to infer the mime type from the signature', () => {
|
||||
// https://en.wikipedia.org/wiki/List_of_file_signatures
|
||||
|
||||
// PNG
|
||||
expect(getMimeTypeFromBase64({ base64String: 'iVBORw0KGgoAAAANSUhEUgAAAAUA' })).to.deep.equal({ mimeType: 'image/png' });
|
||||
expect(getMimeTypeFromBase64({ base64String: 'iVBORw0KGgoAAAANSUhEUgAAAAUA' })).to.deep.equal({
|
||||
mimeType: 'image/png',
|
||||
});
|
||||
|
||||
// GIF
|
||||
expect(getMimeTypeFromBase64({ base64String: 'R0lGODdh' })).to.deep.equal({ mimeType: 'image/gif' });
|
||||
|
||||
@@ -5,27 +5,31 @@ import { get } from '@vueuse/core';
|
||||
|
||||
export {
|
||||
getMimeTypeFromBase64,
|
||||
getMimeTypeFromExtension, getExtensionFromMimeType,
|
||||
useDownloadFileFromBase64, useDownloadFileFromBase64Refs,
|
||||
getMimeTypeFromExtension,
|
||||
getExtensionFromMimeType,
|
||||
useDownloadFileFromBase64,
|
||||
useDownloadFileFromBase64Refs,
|
||||
previewImageFromBase64,
|
||||
};
|
||||
|
||||
const commonMimeTypesSignatures = {
|
||||
'JVBERi0': 'application/pdf',
|
||||
'R0lGODdh': 'image/gif',
|
||||
'R0lGODlh': 'image/gif',
|
||||
'iVBORw0KGgo': 'image/png',
|
||||
JVBERi0: 'application/pdf',
|
||||
R0lGODdh: 'image/gif',
|
||||
R0lGODlh: 'image/gif',
|
||||
iVBORw0KGgo: 'image/png',
|
||||
'/9j/': 'image/jpg',
|
||||
};
|
||||
|
||||
function getMimeTypeFromBase64({ base64String }: { base64String: string }) {
|
||||
const [,mimeTypeFromBase64] = base64String.match(/data:(.*?);base64/i) ?? [];
|
||||
const [, mimeTypeFromBase64] = base64String.match(/data:(.*?);base64/i) ?? [];
|
||||
|
||||
if (mimeTypeFromBase64) {
|
||||
return { mimeType: mimeTypeFromBase64 };
|
||||
}
|
||||
|
||||
const inferredMimeType = _.find(commonMimeTypesSignatures, (_mimeType, signature) => base64String.startsWith(signature));
|
||||
const inferredMimeType = _.find(commonMimeTypesSignatures, (_mimeType, signature) =>
|
||||
base64String.startsWith(signature),
|
||||
);
|
||||
|
||||
if (inferredMimeType) {
|
||||
return { mimeType: inferredMimeType };
|
||||
@@ -38,8 +42,8 @@ function getFileExtensionFromMimeType({
|
||||
mimeType,
|
||||
defaultExtension = 'txt',
|
||||
}: {
|
||||
mimeType: string | undefined
|
||||
defaultExtension?: string
|
||||
mimeType: string | undefined;
|
||||
defaultExtension?: string;
|
||||
}) {
|
||||
if (mimeType) {
|
||||
return getExtensionFromMimeType(mimeType) ?? defaultExtension;
|
||||
@@ -48,8 +52,17 @@ function getFileExtensionFromMimeType({
|
||||
return defaultExtension;
|
||||
}
|
||||
|
||||
function downloadFromBase64({ sourceValue, filename, extension, fileMimeType }:
|
||||
{ sourceValue: string; filename?: string; extension?: string; fileMimeType?: string }) {
|
||||
function downloadFromBase64({
|
||||
sourceValue,
|
||||
filename,
|
||||
extension,
|
||||
fileMimeType,
|
||||
}: {
|
||||
sourceValue: string;
|
||||
filename?: string;
|
||||
extension?: string;
|
||||
fileMimeType?: string;
|
||||
}) {
|
||||
if (sourceValue === '') {
|
||||
throw new Error('Base64 string is empty');
|
||||
}
|
||||
@@ -62,8 +75,7 @@ function downloadFromBase64({ sourceValue, filename, extension, fileMimeType }:
|
||||
base64String = `data:${targetMimeType};base64,${sourceValue}`;
|
||||
}
|
||||
|
||||
const cleanExtension = extension ?? getFileExtensionFromMimeType(
|
||||
{ mimeType, defaultExtension });
|
||||
const cleanExtension = extension ?? getFileExtensionFromMimeType({ mimeType, defaultExtension });
|
||||
let cleanFileName = filename ?? `file.${cleanExtension}`;
|
||||
if (extension && !cleanFileName.endsWith(`.${extension}`)) {
|
||||
cleanFileName = `${cleanFileName}.${cleanExtension}`;
|
||||
@@ -75,9 +87,15 @@ function downloadFromBase64({ sourceValue, filename, extension, fileMimeType }:
|
||||
a.click();
|
||||
}
|
||||
|
||||
function useDownloadFileFromBase64(
|
||||
{ source, filename, extension }:
|
||||
{ source: MaybeRef<string>; filename?: MaybeRef<string>; extension?: MaybeRef<string> }) {
|
||||
function useDownloadFileFromBase64({
|
||||
source,
|
||||
filename,
|
||||
extension,
|
||||
}: {
|
||||
source: MaybeRef<string>;
|
||||
filename?: MaybeRef<string>;
|
||||
extension?: MaybeRef<string>;
|
||||
}) {
|
||||
return {
|
||||
download() {
|
||||
downloadFromBase64({ sourceValue: get(source), filename: get(filename), extension: get(extension) });
|
||||
@@ -105,17 +123,22 @@ function previewImageFromBase64(base64String: string): HTMLImageElement {
|
||||
if (previewContainer) {
|
||||
previewContainer.innerHTML = '';
|
||||
previewContainer.appendChild(container);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new Error('Preview container element not found');
|
||||
}
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
function useDownloadFileFromBase64Refs(
|
||||
{ source, filename, extension }:
|
||||
{ source: Ref<string>; filename?: Ref<string>; extension?: Ref<string> }) {
|
||||
function useDownloadFileFromBase64Refs({
|
||||
source,
|
||||
filename,
|
||||
extension,
|
||||
}: {
|
||||
source: Ref<string>;
|
||||
filename?: Ref<string>;
|
||||
extension?: Ref<string>;
|
||||
}) {
|
||||
return {
|
||||
download() {
|
||||
downloadFromBase64({ sourceValue: source.value, filename: filename?.value, extension: extension?.value });
|
||||
|
||||
@@ -14,10 +14,10 @@ function useFuzzySearch<Data>({
|
||||
options = {},
|
||||
limit = -1,
|
||||
}: {
|
||||
search: MaybeRef<string>
|
||||
data: Data[]
|
||||
options?: IFuseOptions<Data> & { filterEmpty?: boolean }
|
||||
limit?: number
|
||||
search: MaybeRef<string>;
|
||||
data: Data[];
|
||||
options?: IFuseOptions<Data> & { filterEmpty?: boolean };
|
||||
limit?: number;
|
||||
}) {
|
||||
const fuse = new Fuse(data, options);
|
||||
const filterEmpty = options.filterEmpty ?? true;
|
||||
|
||||
@@ -26,7 +26,15 @@ const transformers = {
|
||||
},
|
||||
};
|
||||
|
||||
function useQueryParam<T>({ tool, name, defaultValue }: { tool: string; name: string; defaultValue: T }): RemovableRef<T> {
|
||||
function useQueryParam<T>({
|
||||
tool,
|
||||
name,
|
||||
defaultValue,
|
||||
}: {
|
||||
tool: string;
|
||||
name: string;
|
||||
defaultValue: T;
|
||||
}): RemovableRef<T> {
|
||||
const type = typeof defaultValue;
|
||||
const transformer = transformers[type as keyof typeof transformers] ?? transformers.string;
|
||||
const defaultValueOrSetting = getITToolsSetting(`${tool}:${name}`, defaultValue);
|
||||
@@ -43,7 +51,15 @@ function useQueryParam<T>({ tool, name, defaultValue }: { tool: string; name: st
|
||||
});
|
||||
}
|
||||
|
||||
function useQueryParamOrStorage<T>({ name, storageName, defaultValue }: { name: string; storageName: string; defaultValue: T }) {
|
||||
function useQueryParamOrStorage<T>({
|
||||
name,
|
||||
storageName,
|
||||
defaultValue,
|
||||
}: {
|
||||
name: string;
|
||||
storageName: string;
|
||||
defaultValue: T;
|
||||
}) {
|
||||
const type = typeof defaultValue;
|
||||
const transformer = transformers[type as keyof typeof transformers] ?? transformers.string;
|
||||
|
||||
@@ -53,23 +69,32 @@ function useQueryParamOrStorage<T>({ name, storageName, defaultValue }: { name:
|
||||
const proxyDefaultValue = transformer.toQuery(defaultValueOrSetting as never);
|
||||
const proxy = useRouteQuery(name, proxyDefaultValue);
|
||||
|
||||
const r = isRef(defaultValueOrSetting) ? defaultValueOrSetting as Ref<T> : ref(get(defaultValueOrSetting));
|
||||
const r = isRef(defaultValueOrSetting) ? (defaultValueOrSetting as Ref<T>) : ref(get(defaultValueOrSetting));
|
||||
|
||||
watch(r,
|
||||
watch(
|
||||
r,
|
||||
(value) => {
|
||||
proxy.value = transformer.toQuery(value as never);
|
||||
storageRef.value = value as never;
|
||||
},
|
||||
{ deep: true });
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
r.value = (proxy.value && proxy.value !== proxyDefaultValue
|
||||
? transformer.fromQuery(proxy.value) as unknown as T
|
||||
: storageRef.value as T) as never;
|
||||
r.value = (
|
||||
proxy.value && proxy.value !== proxyDefaultValue
|
||||
? (transformer.fromQuery(proxy.value) as unknown as T)
|
||||
: (storageRef.value as T)
|
||||
) as never;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
function useITStorage<T>(key: string, defaults: MaybeRef<T>, storage?: StorageLike, options?: UseStorageOptions<T>): RemovableRef<T> {
|
||||
function useITStorage<T>(
|
||||
key: string,
|
||||
defaults: MaybeRef<T>,
|
||||
storage?: StorageLike,
|
||||
options?: UseStorageOptions<T>,
|
||||
): RemovableRef<T> {
|
||||
const defaultValueOrSetting = getITToolsSetting(key, defaults);
|
||||
return useStorage<T>(key, defaultValueOrSetting, storage, options);
|
||||
}
|
||||
@@ -81,10 +106,9 @@ function getITToolsSetting<T>(key: string, defaultValue: MaybeRef<T>) {
|
||||
}
|
||||
if (key.includes(':')) {
|
||||
const [tool, subkey] = key.split(':');
|
||||
return (itToolsSettings[tool] || {})[subkey] as T ?? defaultValue;
|
||||
}
|
||||
else {
|
||||
return (itToolsSettings)[key] as T ?? defaultValue;
|
||||
return ((itToolsSettings[tool] || {})[subkey] as T) ?? defaultValue;
|
||||
} else {
|
||||
return (itToolsSettings[key] as T) ?? defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ type ValidatorReturnType = unknown;
|
||||
type GetErrorMessageReturnType = string;
|
||||
|
||||
export interface UseValidationRule<T> {
|
||||
validator: (value: T) => ValidatorReturnType
|
||||
getErrorMessage?: (value: T) => GetErrorMessageReturnType
|
||||
message: string
|
||||
validator: (value: T) => ValidatorReturnType;
|
||||
getErrorMessage?: (value: T) => GetErrorMessageReturnType;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export function isFalsyOrHasThrown(cb: () => ValidatorReturnType): boolean {
|
||||
@@ -20,8 +20,7 @@ export function isFalsyOrHasThrown(cb: () => ValidatorReturnType): boolean {
|
||||
}
|
||||
|
||||
return returnValue === false;
|
||||
}
|
||||
catch (_) {
|
||||
} catch (_) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -29,15 +28,14 @@ export function isFalsyOrHasThrown(cb: () => ValidatorReturnType): boolean {
|
||||
export function getErrorMessageOrThrown(cb: () => GetErrorMessageReturnType): string {
|
||||
try {
|
||||
return cb() || '';
|
||||
}
|
||||
catch (e: any) {
|
||||
} catch (e: any) {
|
||||
return e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
export interface ValidationAttrs {
|
||||
feedback: string
|
||||
validationStatus: string | undefined
|
||||
feedback: string;
|
||||
validationStatus: string | undefined;
|
||||
}
|
||||
|
||||
export function useValidation<T>({
|
||||
@@ -45,15 +43,15 @@ export function useValidation<T>({
|
||||
rules,
|
||||
watch: watchRefs = [],
|
||||
}: {
|
||||
source: Ref<T>
|
||||
rules: MaybeRef<UseValidationRule<T>[]>
|
||||
watch?: Ref<unknown>[]
|
||||
source: Ref<T>;
|
||||
rules: MaybeRef<UseValidationRule<T>[]>;
|
||||
watch?: Ref<unknown>[];
|
||||
}) {
|
||||
const state = reactive<{
|
||||
message: string
|
||||
status: undefined | 'error'
|
||||
isValid: boolean
|
||||
attrs: ValidationAttrs
|
||||
message: string;
|
||||
status: undefined | 'error';
|
||||
isValid: boolean;
|
||||
attrs: ValidationAttrs;
|
||||
}>({
|
||||
message: '',
|
||||
status: undefined,
|
||||
@@ -74,9 +72,11 @@ export function useValidation<T>({
|
||||
if (isFalsyOrHasThrown(() => rule.validator(source.value))) {
|
||||
if (rule.getErrorMessage) {
|
||||
const getErrorMessage = rule.getErrorMessage;
|
||||
state.message = rule.message.replace('{0}', getErrorMessageOrThrown(() => getErrorMessage(source.value)));
|
||||
}
|
||||
else {
|
||||
state.message = rule.message.replace(
|
||||
'{0}',
|
||||
getErrorMessageOrThrown(() => getErrorMessage(source.value)),
|
||||
);
|
||||
} else {
|
||||
state.message = rule.message;
|
||||
}
|
||||
state.status = 'error';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { figue } from 'figue';
|
||||
import { appBaseUrl } from '@/utils/base-url';
|
||||
|
||||
export const config = figue({
|
||||
app: {
|
||||
@@ -18,6 +19,8 @@ export const config = figue({
|
||||
doc: 'Application base url',
|
||||
format: 'string',
|
||||
default: '/',
|
||||
// Not import.meta.env.BASE_URL: the bundle is built path-agnostic, so the real
|
||||
// base only shows up at runtime. See src/utils/base-url.ts.
|
||||
env: 'BASE_URL',
|
||||
},
|
||||
env: {
|
||||
@@ -70,6 +73,7 @@ export const config = figue({
|
||||
...import.meta.env,
|
||||
// Because the string 'import.meta.env.PACKAGE_VERSION' is statically replaced during build time (see 'define' in vite.config.ts)
|
||||
PACKAGE_VERSION: import.meta.env.PACKAGE_VERSION,
|
||||
BASE_URL: appBaseUrl,
|
||||
})
|
||||
.validate()
|
||||
.getConfig();
|
||||
@@ -27,13 +27,15 @@ watchEffect(() => {
|
||||
document.documentElement.style.setProperty('--app-topbar-height', `${Math.round(navbarHeight.value)}px`);
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
const { t, locale } = useI18n();
|
||||
|
||||
const toolStore = useToolStore();
|
||||
const { favoriteTools, toolsByCategory } = storeToRefs(toolStore);
|
||||
|
||||
const tools = computed<ToolCategory[]>(() => [
|
||||
...(favoriteTools.value.length > 0 ? [{ name: t('tools.categories.favorite-tools'), components: favoriteTools.value }] : []),
|
||||
...(favoriteTools.value.length > 0
|
||||
? [{ name: t('tools.categories.favorite-tools'), components: favoriteTools.value }]
|
||||
: []),
|
||||
...toolsByCategory.value,
|
||||
]);
|
||||
</script>
|
||||
@@ -44,9 +46,7 @@ const tools = computed<ToolCategory[]>(() => [
|
||||
<RouterLink to="/" class="hero-wrapper">
|
||||
<HeroGradient class="gradient" />
|
||||
<div class="text-wrapper">
|
||||
<div class="title">
|
||||
IT - TOOLS
|
||||
</div>
|
||||
<div class="title">IT - TOOLS</div>
|
||||
<div class="divider" />
|
||||
<div class="subtitle">
|
||||
{{ $t('home.subtitle') }}
|
||||
@@ -109,12 +109,20 @@ const tools = computed<ToolCategory[]>(() => [
|
||||
</c-tooltip>
|
||||
|
||||
<c-tooltip :tooltip="$t('home.uiLib')" position="bottom">
|
||||
<c-button v-if="config.app.env === 'development'" to="/c-lib" circle variant="text" :aria-label="$t('home.uiLib')">
|
||||
<c-button
|
||||
v-if="config.app.env === 'development'"
|
||||
to="/c-lib"
|
||||
circle
|
||||
variant="text"
|
||||
:aria-label="$t('home.uiLib')"
|
||||
>
|
||||
<icon-mdi:brush-variant text-20px />
|
||||
</c-button>
|
||||
</c-tooltip>
|
||||
|
||||
<command-palette />
|
||||
<Suspense>
|
||||
<command-palette :key="locale" />
|
||||
</Suspense>
|
||||
|
||||
<div>
|
||||
<NavbarButtons v-if="!styleStore.isSmallScreen" />
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import BaseLayout from './base.layout.vue';
|
||||
import PassthroughLayout from './passthrough.layout.vue';
|
||||
import ToolLayout from './tool.layout.vue';
|
||||
|
||||
// BaseLayout is not here: App.vue renders it once around the switch, so it
|
||||
// survives navigation instead of being remounted with every route.
|
||||
export const layouts = {
|
||||
base: BaseLayout,
|
||||
base: PassthroughLayout,
|
||||
toolLayout: ToolLayout,
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
<!-- Layout for routes wanting no chrome beyond the app shell; BaseLayout is
|
||||
rendered once in App.vue so the sider is not rebuilt on every navigation. -->
|
||||
<template>
|
||||
<slot />
|
||||
</template>
|
||||
+39
-42
@@ -12,7 +12,6 @@ const VueMarkdown = defineAsyncComponent(() => import('vue-markdown-render'));
|
||||
|
||||
import { useThemeVars } from 'naive-ui';
|
||||
import { useTheme } from '../ui/c-link/c-link.theme';
|
||||
import BaseLayout from './base.layout.vue';
|
||||
import FavoriteButton from '@/components/FavoriteButton.vue';
|
||||
import type { Tool } from '@/tools/tools.types';
|
||||
|
||||
@@ -63,7 +62,7 @@ const toolTitle = computed<string>(() => t(`tools.${i18nKey.value}.title`, Strin
|
||||
const toolDescription = computed<string>(() => t(`tools.${i18nKey.value}.description`, String(route.meta.description)));
|
||||
const toolFooter = computed<string>(() => {
|
||||
const createLink = (linkText: string, url: string) => {
|
||||
return `[${linkText.replace('[', '\\[').replace(']', '\\]')}](${url.replace('(', '%28').replace(')', '%29')})`;
|
||||
return `[${linkText.replace(/[\\[\]]/g, '\\$&')}](${url.replace(/\(/g, '%28').replace(/\)/g, '%29')})`;
|
||||
};
|
||||
let footer = t(`tools.${i18nKey.value}.footer`, String(route.meta.footer));
|
||||
if (footer === 'undefined') {
|
||||
@@ -83,51 +82,49 @@ const linkTheme = useTheme();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BaseLayout>
|
||||
<div class="tool-layout">
|
||||
<div class="tool-header">
|
||||
<div flex flex-nowrap items-center justify-between>
|
||||
<n-h1>
|
||||
{{ toolTitle }}
|
||||
<n-tooltip placement="right" trigger="click" content-class="tool-privacy-info">
|
||||
<template #trigger>
|
||||
<World v-if="route.meta.externAccessDescription" class="tool-privacy-icon" />
|
||||
<DeviceDesktop v-else class="tool-privacy-icon" />
|
||||
</template>
|
||||
<VueMarkdown
|
||||
v-if="route.meta.externAccessDescription"
|
||||
:source="route.meta.externAccessDescription as string"
|
||||
:options="{ linkify: true }"
|
||||
/>
|
||||
<template v-else>
|
||||
{{ $t('tools.tool.layout.text.runs-entirely-in-your-browser-no-external-requests') }}
|
||||
</template>
|
||||
</n-tooltip>
|
||||
</n-h1>
|
||||
<div class="tool-layout">
|
||||
<div class="tool-header">
|
||||
<div flex flex-nowrap items-center justify-between>
|
||||
<n-h1>
|
||||
{{ toolTitle }}
|
||||
<n-tooltip placement="right" trigger="click" content-class="tool-privacy-info">
|
||||
<template #trigger>
|
||||
<World v-if="route.meta.externAccessDescription" class="tool-privacy-icon" />
|
||||
<DeviceDesktop v-else class="tool-privacy-icon" />
|
||||
</template>
|
||||
<VueMarkdown
|
||||
v-if="route.meta.externAccessDescription"
|
||||
:source="route.meta.externAccessDescription as string"
|
||||
:options="{ linkify: true }"
|
||||
/>
|
||||
<template v-else>
|
||||
{{ $t('tools.tool.layout.text.runs-entirely-in-your-browser-no-external-requests') }}
|
||||
</template>
|
||||
</n-tooltip>
|
||||
</n-h1>
|
||||
|
||||
<div>
|
||||
<FavoriteButton :tool="{ name: route.meta.name, path: route.path } as Tool" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="separator" />
|
||||
|
||||
<div class="description">
|
||||
{{ toolDescription }}
|
||||
<div>
|
||||
<FavoriteButton :tool="{ name: route.meta.name, path: route.path } as Tool" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tool-content">
|
||||
<Suspense>
|
||||
<slot />
|
||||
</Suspense>
|
||||
</div>
|
||||
<div class="separator" />
|
||||
|
||||
<div class="tool-footer">
|
||||
<VueMarkdown :source="toolFooter" />
|
||||
<div class="description">
|
||||
{{ toolDescription }}
|
||||
</div>
|
||||
</div>
|
||||
</BaseLayout>
|
||||
</div>
|
||||
|
||||
<div class="tool-content">
|
||||
<Suspense>
|
||||
<slot />
|
||||
</Suspense>
|
||||
</div>
|
||||
|
||||
<div class="tool-footer">
|
||||
<VueMarkdown :source="toolFooter" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less">
|
||||
@@ -156,7 +153,7 @@ const linkTheme = useTheme();
|
||||
gap: 16px;
|
||||
overflow-x: auto;
|
||||
|
||||
::v-deep(& > *) {
|
||||
> :deep(*) {
|
||||
flex: 0 1 1200px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
+48
-2
@@ -5,12 +5,15 @@ import { LoadingPlugin } from 'vue-loading-overlay';
|
||||
|
||||
import { installAbortSignalPolyfill } from 'abort-signal-polyfill';
|
||||
|
||||
import { registerSW } from 'virtual:pwa-register';
|
||||
import shadow from 'vue-shadow-dom';
|
||||
import { plausible } from './plugins/plausible.plugin';
|
||||
import { appBaseUrl } from '@/utils/base-url';
|
||||
import '@/utils/json5-bigint';
|
||||
import '@/utils/json5-bignum';
|
||||
|
||||
import Vue3Katex from 'vue3-katex';
|
||||
import 'katex/dist/katex.min.css';
|
||||
|
||||
import 'virtual:uno.css';
|
||||
|
||||
import { naive } from './plugins/naive.plugin';
|
||||
@@ -34,7 +37,49 @@ window.addEventListener('vite:preloadError', (event: Event) => {
|
||||
|
||||
installAbortSignalPolyfill();
|
||||
|
||||
registerSW();
|
||||
// Not `registerSW()` from virtual:pwa-register. With a relative build base it hands
|
||||
// workbox-window a relative `./sw.js`, and while the browser resolves that against our
|
||||
// `<base href>` correctly, workbox-window's own bookkeeping resolves it against
|
||||
// `location.href` instead (urlsMatch() in workbox-window). On a route one level deeper
|
||||
// than the app root the two disagree, workbox mistakes its own worker for an external one
|
||||
// and reloads the page under the user. Every route is a single segment today, so nothing
|
||||
// is broken right now; registering by absolute URL just takes the trap away.
|
||||
//
|
||||
// What that costs us is the update handling `registerType: 'autoUpdate'` would have wired
|
||||
// up, so it is reimplemented below.
|
||||
if (import.meta.env.PROD && 'serviceWorker' in navigator) {
|
||||
// The worker calls skipWaiting()/clientsClaim() (see vite.config.ts), so a newly deployed
|
||||
// one takes over this page while it is still showing the previous build. Reload when that
|
||||
// happens -- otherwise the tab keeps running the old bundle until it navigates, and any
|
||||
// lazily imported chunk it reaches for has already been swept from the cache. A first
|
||||
// install claims the page too, and must not reload: only a *replacement* means the page
|
||||
// and its worker have diverged.
|
||||
const hadController = Boolean(navigator.serviceWorker.controller);
|
||||
let reloading = false;
|
||||
|
||||
navigator.serviceWorker.addEventListener('controllerchange', () => {
|
||||
if (hadController && !reloading) {
|
||||
reloading = true;
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
const registerServiceWorker = () => {
|
||||
navigator.serviceWorker
|
||||
.register(`${appBaseUrl}sw.js`, { scope: appBaseUrl })
|
||||
.catch((error) => console.error('Service worker registration failed:', error));
|
||||
};
|
||||
|
||||
// Registering competes with the page's own loading, so it waits for `load` -- but this
|
||||
// module sits behind top-level awaits (the config fetches in tools-settings.ts and
|
||||
// tools/index.ts), so `load` has usually fired long before we get here and waiting for
|
||||
// it again would mean never registering at all.
|
||||
if (document.readyState === 'complete') {
|
||||
registerServiceWorker();
|
||||
} else {
|
||||
window.addEventListener('load', registerServiceWorker, { once: true });
|
||||
}
|
||||
}
|
||||
|
||||
const app = createApp(App);
|
||||
|
||||
@@ -49,5 +94,6 @@ app.use(naive);
|
||||
app.use(plausible);
|
||||
app.use(shadow);
|
||||
app.use(store, 'pomodoro-store');
|
||||
app.use(Vue3Katex);
|
||||
|
||||
app.mount('#app');
|
||||
@@ -11,85 +11,89 @@ import DiceIcon from '~icons/mdi/dice-5';
|
||||
import InfoIcon from '~icons/mdi/information-outline';
|
||||
import { useFlexSearch } from '@/composable/flexSearch';
|
||||
|
||||
import { translate as t } from '@/plugins/i18n.plugin';
|
||||
|
||||
const maxSearchResultsPerCategory = import.meta.env.VITE_MAX_SEARCH_RESULT || 25;
|
||||
|
||||
export const useCommandPaletteStore = defineStore('command-palette', () => {
|
||||
const toolStore = useToolStore();
|
||||
const styleStore = useStyleStore();
|
||||
const router = useRouter();
|
||||
const searchPrompt = ref('');
|
||||
export const useCommandPaletteStore = (locale: string) =>
|
||||
defineStore(`command-palette-${locale}`, () => {
|
||||
const toolStore = useToolStore();
|
||||
const styleStore = useStyleStore();
|
||||
const router = useRouter();
|
||||
const searchPrompt = ref('');
|
||||
|
||||
const toolsOptions = toolStore.tools.map(tool => ({
|
||||
...tool,
|
||||
to: tool.path,
|
||||
toolCategory: tool.category,
|
||||
category: 'Tools',
|
||||
}));
|
||||
const toolsOptions = toolStore.tools.map((tool) => ({
|
||||
...tool,
|
||||
to: tool.path,
|
||||
toolCategory: tool.category,
|
||||
category: t('tools.command-palette.store.texts.tools'),
|
||||
}));
|
||||
|
||||
const searchOptions: PaletteOption[] = [
|
||||
...toolsOptions,
|
||||
{
|
||||
name: 'Random tool',
|
||||
description: 'Get a random tool from the list.',
|
||||
action: () => {
|
||||
const { path } = _.sample(toolStore.tools)!;
|
||||
router.push(path);
|
||||
const searchOptions: PaletteOption[] = [
|
||||
...toolsOptions,
|
||||
{
|
||||
name: t('tools.command-palette.store.texts.random-tool'),
|
||||
description: t('tools.command-palette.store.texts.get-a-random-tool-from-the-list'),
|
||||
action: () => {
|
||||
const { path } = _.sample(toolStore.tools)!;
|
||||
router.push(path);
|
||||
},
|
||||
icon: DiceIcon,
|
||||
category: t('tools.command-palette.store.texts.tools-0'),
|
||||
keywords: ['random', 'tool', 'pick', 'choose', 'select'],
|
||||
closeOnSelect: true,
|
||||
},
|
||||
icon: DiceIcon,
|
||||
category: 'Tools',
|
||||
keywords: ['random', 'tool', 'pick', 'choose', 'select'],
|
||||
closeOnSelect: true,
|
||||
},
|
||||
{
|
||||
name: 'Toggle dark mode',
|
||||
description: 'Toggle dark mode on or off.',
|
||||
action: () => styleStore.toggleDark(),
|
||||
icon: SunIcon,
|
||||
category: 'Actions',
|
||||
keywords: ['dark', 'theme', 'toggle', 'mode', 'light', 'system'],
|
||||
},
|
||||
{
|
||||
name: 'Github repository',
|
||||
href: 'https://github.com/sharevb/it-tools',
|
||||
category: 'External',
|
||||
description: 'View the source code of it-tools on Github.',
|
||||
keywords: ['github', 'repo', 'repository', 'source', 'code'],
|
||||
icon: GithubIcon,
|
||||
},
|
||||
{
|
||||
name: 'Report a bug or an issue',
|
||||
description: 'Report a bug or an issue to help improve it-tools.',
|
||||
href: 'https://github.com/sharevb/it-tools/issues/new/choose',
|
||||
category: 'Actions',
|
||||
keywords: ['report', 'issue', 'bug', 'problem', 'error'],
|
||||
icon: BugIcon,
|
||||
},
|
||||
{
|
||||
name: 'About',
|
||||
description: 'Learn more about IT-Tools.',
|
||||
to: '/about',
|
||||
category: 'Pages',
|
||||
keywords: ['about', 'learn', 'more', 'info', 'information'],
|
||||
icon: InfoIcon,
|
||||
},
|
||||
];
|
||||
{
|
||||
name: t('tools.command-palette.store.texts.toggle-dark-mode'),
|
||||
description: t('tools.command-palette.store.texts.toggle-dark-mode-on-or-off'),
|
||||
action: () => styleStore.toggleDark(),
|
||||
icon: SunIcon,
|
||||
category: t('tools.command-palette.store.texts.actions'),
|
||||
keywords: ['dark', 'theme', 'toggle', 'mode', 'light', 'system'],
|
||||
},
|
||||
{
|
||||
name: t('tools.command-palette.store.texts.github-repository'),
|
||||
href: 'https://github.com/sharevb/it-tools',
|
||||
category: t('tools.command-palette.store.texts.external'),
|
||||
description: t('tools.command-palette.store.texts.view-the-source-code-of-it-tools-on-github'),
|
||||
keywords: ['github', 'repo', 'repository', 'source', 'code'],
|
||||
icon: GithubIcon,
|
||||
},
|
||||
{
|
||||
name: t('tools.command-palette.store.texts.report-a-bug-or-an-issue'),
|
||||
description: t('tools.command-palette.store.texts.report-a-bug-or-an-issue-to-help-improve-it-tools'),
|
||||
href: 'https://github.com/sharevb/it-tools/issues/new/choose',
|
||||
category: t('tools.command-palette.store.texts.actions-0'),
|
||||
keywords: ['report', 'issue', 'bug', 'problem', 'error'],
|
||||
icon: BugIcon,
|
||||
},
|
||||
{
|
||||
name: t('tools.pomodoro-timer.PomodoroApp.text.about'),
|
||||
description: t('tools.command-palette.store.texts.learn-more-about-it-tools'),
|
||||
to: '/about',
|
||||
category: t('tools.command-palette.store.texts.pages'),
|
||||
keywords: ['about', 'learn', 'more', 'info', 'information'],
|
||||
icon: InfoIcon,
|
||||
},
|
||||
];
|
||||
|
||||
const { searchResult } = useFlexSearch({
|
||||
search: searchPrompt,
|
||||
data: searchOptions,
|
||||
options: {
|
||||
keys: [{ name: 'name', weight: 2 }, 'description', 'keywords', 'category'],
|
||||
},
|
||||
});
|
||||
const { searchResult } = useFlexSearch({
|
||||
search: searchPrompt,
|
||||
data: searchOptions,
|
||||
options: {
|
||||
keys: [{ name: 'name', weight: 2 }, 'description', 'keywords', 'category'],
|
||||
},
|
||||
});
|
||||
|
||||
const filteredSearchResult = computed(() =>
|
||||
_.mapValues(
|
||||
_.groupBy(searchResult.value, option => option.category),
|
||||
categoryOptions => categoryOptions.slice(0, maxSearchResultsPerCategory),
|
||||
));
|
||||
const filteredSearchResult = computed(() =>
|
||||
_.mapValues(
|
||||
_.groupBy(searchResult.value, (option) => option.category),
|
||||
(categoryOptions) => categoryOptions.slice(0, maxSearchResultsPerCategory),
|
||||
),
|
||||
);
|
||||
|
||||
return {
|
||||
filteredSearchResult,
|
||||
searchPrompt,
|
||||
};
|
||||
});
|
||||
return {
|
||||
filteredSearchResult,
|
||||
searchPrompt,
|
||||
};
|
||||
})();
|
||||
@@ -2,14 +2,14 @@ import type { Component } from 'vue';
|
||||
import type { RouteLocationRaw } from 'vue-router';
|
||||
|
||||
export interface PaletteOption {
|
||||
name: string
|
||||
description?: string
|
||||
icon?: Component
|
||||
action?: () => void
|
||||
to?: RouteLocationRaw
|
||||
category: string
|
||||
keywords?: string[]
|
||||
href?: string
|
||||
closeOnSelect?: boolean
|
||||
externAccessDescription?: string
|
||||
name: string;
|
||||
description?: string;
|
||||
icon?: Component;
|
||||
action?: () => void;
|
||||
to?: RouteLocationRaw;
|
||||
category: string;
|
||||
keywords?: string[];
|
||||
href?: string;
|
||||
closeOnSelect?: boolean;
|
||||
externAccessDescription?: string;
|
||||
}
|
||||
@@ -3,13 +3,17 @@ import { storeToRefs } from 'pinia';
|
||||
import * as _ from 'es-toolkit/compat';
|
||||
import { useCommandPaletteStore } from './command-palette.store';
|
||||
import type { PaletteOption } from './command-palette.types';
|
||||
import { loadLocaleMessages } from '@/plugins/i18n.plugin';
|
||||
|
||||
const isModalOpen = ref(false);
|
||||
const inputRef = ref();
|
||||
const router = useRouter();
|
||||
const isMac = computed(() => window.navigator.userAgent.toLowerCase().includes('mac'));
|
||||
|
||||
const commandPaletteStore = useCommandPaletteStore();
|
||||
const { locale } = useI18n();
|
||||
await loadLocaleMessages(locale.value);
|
||||
|
||||
const commandPaletteStore = useCommandPaletteStore(locale.value);
|
||||
const { searchPrompt, filteredSearchResult } = storeToRefs(commandPaletteStore);
|
||||
|
||||
const keys = useMagicKeys({
|
||||
@@ -32,7 +36,7 @@ whenever(keys.meta_k, open);
|
||||
whenever(keys.escape, close);
|
||||
|
||||
function open() {
|
||||
return isModalOpen.value = true;
|
||||
return (isModalOpen.value = true);
|
||||
}
|
||||
|
||||
function close() {
|
||||
@@ -67,7 +71,9 @@ function handleKeydown(event: KeyboardEvent) {
|
||||
}
|
||||
|
||||
function getOptionIndex(option: PaletteOption) {
|
||||
return Object.values(filteredSearchResult.value).flat().findIndex(o => o === option);
|
||||
return Object.values(filteredSearchResult.value)
|
||||
.flat()
|
||||
.findIndex((o) => o === option);
|
||||
}
|
||||
|
||||
function activateOption(option: PaletteOption) {
|
||||
@@ -108,7 +114,6 @@ function activateOption(option: PaletteOption) {
|
||||
<div flex-1>
|
||||
<c-button w-full important:justify-start @click="isModalOpen = true">
|
||||
<span flex items-center gap-3 op-40>
|
||||
|
||||
<icon-mdi-search />
|
||||
{{ $t('search.label') }}
|
||||
|
||||
@@ -118,14 +123,36 @@ function activateOption(option: PaletteOption) {
|
||||
</span>
|
||||
</c-button>
|
||||
|
||||
<c-modal v-model:open="isModalOpen" class="palette-modal" overflow-y-auto shadow-xl important:max-w-650px pretty-scrollbar important:pa-12px @keydown="handleKeydown">
|
||||
<c-input-text ref="inputRef" v-model:value="searchPrompt" raw-text :placeholder="$t('search.placeholder')" autofocus clearable />
|
||||
<c-modal
|
||||
v-model:open="isModalOpen"
|
||||
class="palette-modal"
|
||||
overflow-y-auto
|
||||
shadow-xl
|
||||
important:max-w-650px
|
||||
pretty-scrollbar
|
||||
important:pa-12px
|
||||
@keydown="handleKeydown"
|
||||
>
|
||||
<c-input-text
|
||||
ref="inputRef"
|
||||
v-model:value="searchPrompt"
|
||||
raw-text
|
||||
:placeholder="$t('search.placeholder')"
|
||||
autofocus
|
||||
clearable
|
||||
/>
|
||||
|
||||
<div v-for="(options, category) in filteredSearchResult" :key="category">
|
||||
<div ml-3 mt-3 text-sm font-bold text-primary op-60>
|
||||
{{ category }}
|
||||
</div>
|
||||
<command-palette-option v-for="option in options" :key="option.name" :option="option" :selected="selectedOptionIndex === getOptionIndex(option)" @activated="activateOption" />
|
||||
<command-palette-option
|
||||
v-for="option in options"
|
||||
:key="option.name"
|
||||
:option="option"
|
||||
:selected="selectedOptionIndex === getOptionIndex(option)"
|
||||
@activated="activateOption"
|
||||
/>
|
||||
</div>
|
||||
</c-modal>
|
||||
</div>
|
||||
@@ -136,8 +163,8 @@ function activateOption(option: PaletteOption) {
|
||||
font-size: 18px;
|
||||
|
||||
::v-deep(.input-wrapper) {
|
||||
padding: 4px;
|
||||
padding-left: 18px;
|
||||
padding: 4px;
|
||||
padding-left: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loaded 100 of 1096 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user