Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
refactor: remove bytes package for manual util (#1752)
Kyle Mendelle3de51b583da
diff --git a/frontend/package.json b/frontend/package.jsonindex 8e9fce308..8da21507d 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -1,77 +1,75 @@{- "name": "arcane-frontend",- "private": true,- "version": "1.15.0",- "type": "module",- "scripts": {- "dev": "vite dev --port 3000 --host",- "build": "vite build",- "preview": "vite preview --port 3000",- "lint-staged": "lint-staged",- "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",- "format": "prettier --write ./src",- "format:check": "prettier --check ./src",- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",- "knip": "knip",- "i18n:unused": "i18n-unused display-unused",- "i18n:remove": "i18n-unused remove-unused",- "i18n:mark": "i18n-unused mark-unused"- },- "dependencies": {- "@shikijs/monaco": "^3.21.0",- "@sveltejs/adapter-static": "^3.0.10",- "@sveltejs/kit": "^2.49.5",- "@tanstack/svelte-query": "^6.0.18",- "@tanstack/table-core": "^8.21.3",- "@xterm/addon-fit": "^0.11.0",- "@xterm/xterm": "^6.0.0",- "ansi-to-html": "^0.7.2",- "axios": "^1.13.5",- "date-fns": "^4.1.0",- "js-yaml": "^4.1.1",- "monaco-editor": "^0.55.1",- "prettier": "^3.8.0",- "prettier-plugin-svelte": "^3.4.1",- "prettier-plugin-tailwindcss": "^0.7.2",- "shiki": "^3.22.0",- "svelte": "^5.51.0",- "svelte-motion": "^0.12.2"- },- "devDependencies": {- "@iconify/json": "^2.2.431",- "@inlang/paraglide-js": "2.9.1",- "@internationalized/date": "^3.11.0",- "@prettier/plugin-oxc": "^0.1.3",- "@sveltejs/vite-plugin-svelte": "^6.2.4",- "@tailwindcss/vite": "^4.1.18",- "@tanstack/eslint-plugin-query": "^5.91.4",- "@tanstack/svelte-query-devtools": "^6.0.4",- "@types/bytes": "^3.1.5",- "@types/js-yaml": "^4.0.9",- "@types/node": "^25.0.10",- "bits-ui": "^2.15.5",- "bytes": "^3.1.2",- "clsx": "^2.1.1",- "formsnap": "^2.0.1",- "isomorphic-dompurify": "^2.35.0",- "knip": "^5.82.1",- "mode-watcher": "^1.1.0",- "paneforge": "^1.0.2",- "runed": "^0.37.0",- "svelte-check": "^4.3.5",- "svelte-sonner": "^1.0.7",- "svelte-toolbelt": "^0.10.6",- "sveltekit-superforms": "^2.29.1",- "tailwind-merge": "^3.4.0",- "tailwind-variants": "^3.2.2",- "tailwindcss": "^4.1.18",- "tsx": "^4.21.0",- "tw-animate-css": "^1.4.0",- "typescript": "^5.9.3",- "unplugin-icons": "^23.0.1",- "vaul-svelte": "1.0.0-next.7",- "vite": "^7.3.1",- "vite-plugin-devtools-json": "^1.0.0",- "zod": "^4.3.6"- }+ "name": "arcane-frontend",+ "private": true,+ "version": "1.15.0",+ "type": "module",+ "scripts": {+ "dev": "vite dev --port 3000 --host",+ "build": "vite build",+ "preview": "vite preview --port 3000",+ "lint-staged": "lint-staged",+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",+ "format": "prettier --write ./src",+ "format:check": "prettier --check ./src",+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",+ "knip": "knip",+ "i18n:unused": "i18n-unused display-unused",+ "i18n:remove": "i18n-unused remove-unused",+ "i18n:mark": "i18n-unused mark-unused"+ },+ "dependencies": {+ "@shikijs/monaco": "^3.21.0",+ "@sveltejs/adapter-static": "^3.0.10",+ "@sveltejs/kit": "^2.49.5",+ "@tanstack/svelte-query": "^6.0.18",+ "@tanstack/table-core": "^8.21.3",+ "@xterm/addon-fit": "^0.11.0",+ "@xterm/xterm": "^6.0.0",+ "ansi-to-html": "^0.7.2",+ "axios": "^1.13.5",+ "date-fns": "^4.1.0",+ "js-yaml": "^4.1.1",+ "monaco-editor": "^0.55.1",+ "prettier": "^3.8.0",+ "prettier-plugin-svelte": "^3.4.1",+ "prettier-plugin-tailwindcss": "^0.7.2",+ "shiki": "^3.22.0",+ "svelte": "^5.51.0",+ "svelte-motion": "^0.12.2"+ },+ "devDependencies": {+ "@iconify/json": "^2.2.431",+ "@inlang/paraglide-js": "2.9.1",+ "@internationalized/date": "^3.11.0",+ "@prettier/plugin-oxc": "^0.1.3",+ "@sveltejs/vite-plugin-svelte": "^6.2.4",+ "@tailwindcss/vite": "^4.1.18",+ "@tanstack/eslint-plugin-query": "^5.91.4",+ "@tanstack/svelte-query-devtools": "^6.0.4",+ "@types/js-yaml": "^4.0.9",+ "@types/node": "^25.0.10",+ "bits-ui": "^2.15.5",+ "clsx": "^2.1.1",+ "formsnap": "^2.0.1",+ "isomorphic-dompurify": "^2.35.0",+ "knip": "^5.82.1",+ "mode-watcher": "^1.1.0",+ "paneforge": "^1.0.2",+ "runed": "^0.37.0",+ "svelte-check": "^4.3.5",+ "svelte-sonner": "^1.0.7",+ "svelte-toolbelt": "^0.10.6",+ "sveltekit-superforms": "^2.29.1",+ "tailwind-merge": "^3.4.0",+ "tailwind-variants": "^3.2.2",+ "tailwindcss": "^4.1.18",+ "tsx": "^4.21.0",+ "tw-animate-css": "^1.4.0",+ "typescript": "^5.9.3",+ "unplugin-icons": "^23.0.1",+ "vaul-svelte": "1.0.0-next.7",+ "vite": "^7.3.1",+ "vite-plugin-devtools-json": "^1.0.0",+ "zod": "^4.3.6"+ }}diff --git a/frontend/src/lib/components/dialogs/docker-info-dialog.svelte b/frontend/src/lib/components/dialogs/docker-info-dialog.svelteindex eccd70106..b6204a5d8 100644--- a/frontend/src/lib/components/dialogs/docker-info-dialog.svelte+++ b/frontend/src/lib/components/dialogs/docker-info-dialog.svelte@@ -5,7 +5,7 @@import { CopyButton } from '$lib/components/ui/copy-button';import type { DockerInfo } from '$lib/types/docker-info.type';import { m } from '$lib/paraglide/messages';- import bytes from 'bytes';+ import bytes from '$lib/utils/bytes';interface Props {open: boolean;diff --git a/frontend/src/lib/components/disk-meter.svelte b/frontend/src/lib/components/disk-meter.svelteindex 4bd55583f..8b3620212 100644--- a/frontend/src/lib/components/disk-meter.svelte+++ b/frontend/src/lib/components/disk-meter.svelte@@ -6,7 +6,7 @@import { Label } from '$lib/components/ui/label';import { Progress } from '$lib/components/ui/progress/index.js';import { m } from '$lib/paraglide/messages';- import bytes from 'bytes';+ import bytes from '$lib/utils/bytes';import settingsStore from '$lib/stores/config-store';import { queryKeys } from '$lib/query/query-keys';import { settingsService } from '$lib/services/settings-service';diff --git a/frontend/src/lib/components/file-browser/FileList.svelte b/frontend/src/lib/components/file-browser/FileList.svelteindex 1c5770657..a2c199b79 100644--- a/frontend/src/lib/components/file-browser/FileList.svelte+++ b/frontend/src/lib/components/file-browser/FileList.svelte@@ -20,7 +20,7 @@import * as Tooltip from '$lib/components/ui/tooltip';import { openConfirmDialog } from '$lib/components/confirm-dialog';import { ArcaneButton } from '$lib/components/arcane-button';- import bytes from 'bytes';+ import bytes from '$lib/utils/bytes';import { format } from 'date-fns';let {diff --git a/frontend/src/lib/components/file-browser/GenericFileBrowser.svelte b/frontend/src/lib/components/file-browser/GenericFileBrowser.svelteindex bb74c5e97..7be853f01 100644--- a/frontend/src/lib/components/file-browser/GenericFileBrowser.svelte+++ b/frontend/src/lib/components/file-browser/GenericFileBrowser.svelte@@ -30,7 +30,7 @@import * as Alert from '$lib/components/ui/alert';import { Label } from '$lib/components/ui/label';import { toast } from 'svelte-sonner';- import bytes from 'bytes';+ import bytes from '$lib/utils/bytes';import { format } from 'date-fns';let { provider, rootLabel, persistKey }: { provider: FileProvider; rootLabel?: string; persistKey?: string } = $props();diff --git a/frontend/src/lib/components/gpu-meter.svelte b/frontend/src/lib/components/gpu-meter.svelteindex abd683f95..f59685965 100644--- a/frontend/src/lib/components/gpu-meter.svelte+++ b/frontend/src/lib/components/gpu-meter.svelte@@ -2,7 +2,7 @@import * as Card from '$lib/components/ui/card';import { Progress } from '$lib/components/ui/progress/index.js';import { m } from '$lib/paraglide/messages';- import bytes from 'bytes';+ import bytes from '$lib/utils/bytes';import type { GPUStats } from '$lib/types/system-stats.type';import { GpuIcon } from '$lib/icons';diff --git a/frontend/src/lib/utils/bytes.ts b/frontend/src/lib/utils/bytes.tsnew file mode 100644index 000000000..2d75b33ec--- /dev/null+++ b/frontend/src/lib/utils/bytes.ts@@ -0,0 +1,135 @@+/*!+ * bytes+ * Copyright(c) 2012-2014 TJ Holowaychuk+ * Copyright(c) 2015 Jed Watson+ * MIT Licensed+ *+ * TypeScript adaptation for Arcane.+ */++export type BytesFormatOptions = {+ decimalPlaces?: number;+ fixedDecimals?: boolean;+ thousandsSeparator?: string;+ unit?: string;+ unitSeparator?: string;+};++export type BytesValue = string | number;++const formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g;+const formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/;++const map = {+ b: 1,+ kb: 1 << 10,+ mb: 1 << 20,+ gb: 1 << 30,+ tb: Math.pow(1024, 4),+ pb: Math.pow(1024, 5)+} as const;++const parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;++type BytesFunction = {+ (value: string, options?: BytesFormatOptions): number | null;+ (value: number, options?: BytesFormatOptions): string | null;+ (value: BytesValue, options?: BytesFormatOptions): string | number | null;+ format: typeof format;+ parse: typeof parse;+};++function bytes(value: string, options?: BytesFormatOptions): number | null;+function bytes(value: number, options?: BytesFormatOptions): string | null;+function bytes(value: BytesValue, options?: BytesFormatOptions): string | number | null {+ if (typeof value === 'string') {+ return parse(value);+ }++ if (typeof value === 'number') {+ return format(value, options);+ }++ return null;+}++export function format(value: number, options?: BytesFormatOptions): string | null {+ if (!Number.isFinite(value)) {+ return null;+ }++ const magnitude = Math.abs(value);+ const thousandsSeparator = options?.thousandsSeparator ?? '';+ const unitSeparator = options?.unitSeparator ?? '';+ const decimalPlaces = options?.decimalPlaces !== undefined ? options.decimalPlaces : 2;+ const fixedDecimals = Boolean(options?.fixedDecimals);+ let unit = options?.unit ?? '';++ const normalizedUnit = unit.toLowerCase() as keyof typeof map;+ if (!unit || !map[normalizedUnit]) {+ if (magnitude >= map.pb) {+ unit = 'PB';+ } else if (magnitude >= map.tb) {+ unit = 'TB';+ } else if (magnitude >= map.gb) {+ unit = 'GB';+ } else if (magnitude >= map.mb) {+ unit = 'MB';+ } else if (magnitude >= map.kb) {+ unit = 'KB';+ } else {+ unit = 'B';+ }+ }++ const divisor = map[unit.toLowerCase() as keyof typeof map];+ const val = value / divisor;+ let str = val.toFixed(decimalPlaces);++ if (!fixedDecimals) {+ str = str.replace(formatDecimalsRegExp, '$1');+ }++ if (thousandsSeparator) {+ str = str+ .split('.')+ .map((part, index) => (index === 0 ? part.replace(formatThousandsRegExp, thousandsSeparator) : part))+ .join('.');+ }++ return str + unitSeparator + unit;+}++export function parse(val: string | number): number | null {+ if (typeof val === 'number' && !Number.isNaN(val)) {+ return val;+ }++ if (typeof val !== 'string') {+ return null;+ }++ const results = parseRegExp.exec(val);+ let floatValue: number;+ let unit: keyof typeof map = 'b';++ if (!results) {+ floatValue = Number.parseInt(val, 10);+ unit = 'b';+ } else {+ floatValue = Number.parseFloat(results[1]);+ unit = results[4].toLowerCase() as keyof typeof map;+ }++ if (Number.isNaN(floatValue)) {+ return null;+ }++ return Math.floor(map[unit] * floatValue);+}++const bytesWithHelpers = bytes as BytesFunction;+bytesWithHelpers.format = format;+bytesWithHelpers.parse = parse;++export default bytesWithHelpers;diff --git a/frontend/src/routes/(app)/containers/[containerId]/+page.svelte b/frontend/src/routes/(app)/containers/[containerId]/+page.svelteindex cd41863e7..3752025e9 100644--- a/frontend/src/routes/(app)/containers/[containerId]/+page.svelte+++ b/frontend/src/routes/(app)/containers/[containerId]/+page.svelte@@ -3,7 +3,7 @@import { invalidateAll } from '$app/navigation';import ActionButtons from '$lib/components/action-buttons.svelte';import StatusBadge from '$lib/components/badges/status-badge.svelte';- import bytes from 'bytes';+ import bytes from '$lib/utils/bytes';import { onDestroy, tick, untrack } from 'svelte';import { page } from '$app/state';import type {diff --git a/frontend/src/routes/(app)/containers/components/ContainerStats.svelte b/frontend/src/routes/(app)/containers/components/ContainerStats.svelteindex a18ce31dd..3173bcc8d 100644--- a/frontend/src/routes/(app)/containers/components/ContainerStats.svelte+++ b/frontend/src/routes/(app)/containers/components/ContainerStats.svelte@@ -3,7 +3,7 @@import { Progress } from '$lib/components/ui/progress';import { Skeleton } from '$lib/components/ui/skeleton';import { m } from '$lib/paraglide/messages';- import bytes from 'bytes';+ import bytes from '$lib/utils/bytes';import type { ContainerDetailsDto, ContainerStats as ContainerStatsType } from '$lib/types/container.type';import { StatsIcon } from '$lib/icons';diff --git a/frontend/src/routes/(app)/containers/components/container-stats-cell.svelte b/frontend/src/routes/(app)/containers/components/container-stats-cell.svelteindex 360f9d641..288dd530e 100644--- a/frontend/src/routes/(app)/containers/components/container-stats-cell.svelte+++ b/frontend/src/routes/(app)/containers/components/container-stats-cell.svelte@@ -1,7 +1,7 @@<script lang="ts">import { Progress } from '$lib/components/ui/progress/index.js';import { m } from '$lib/paraglide/messages';- import bytes from 'bytes';+ import bytes from '$lib/utils/bytes';interface Props {value?: number;diff --git a/frontend/src/routes/(app)/dashboard/+page.svelte b/frontend/src/routes/(app)/dashboard/+page.svelteindex 55f1cfe45..f0c41c98b 100644--- a/frontend/src/routes/(app)/dashboard/+page.svelte+++ b/frontend/src/routes/(app)/dashboard/+page.svelte@@ -19,7 +19,7 @@import { m } from '$lib/paraglide/messages';import { invalidateAll } from '$app/navigation';import { systemService } from '$lib/services/system-service';- import bytes from 'bytes';+ import bytes from '$lib/utils/bytes';import { CpuIcon, MemoryStickIcon } from '$lib/icons';let { data } = $props();diff --git a/frontend/src/routes/(app)/dashboard/dash-image-table.svelte b/frontend/src/routes/(app)/dashboard/dash-image-table.svelteindex a3cb7af06..523fc0016 100644--- a/frontend/src/routes/(app)/dashboard/dash-image-table.svelte+++ b/frontend/src/routes/(app)/dashboard/dash-image-table.svelte@@ -5,7 +5,7 @@import StatusBadge from '$lib/components/badges/status-badge.svelte';import type { SearchPaginationSortRequest, Paginated } from '$lib/types/pagination.type';import type { ImageSummaryDto } from '$lib/types/image.type';- import bytes from 'bytes';+ import bytes from '$lib/utils/bytes';import type { ColumnSpec } from '$lib/components/arcane-table';import { UniversalMobileCard } from '$lib/components/arcane-table';import { m } from '$lib/paraglide/messages';diff --git a/frontend/src/routes/(app)/images/+page.svelte b/frontend/src/routes/(app)/images/+page.svelteindex 455eecec5..36681fa6d 100644--- a/frontend/src/routes/(app)/images/+page.svelte+++ b/frontend/src/routes/(app)/images/+page.svelte@@ -3,7 +3,7 @@import { Spinner } from '$lib/components/ui/spinner/index.js';import { toast } from 'svelte-sonner';import ImagePullSheet from '$lib/components/sheets/image-pull-sheet.svelte';- import bytes from 'bytes';+ import bytes from '$lib/utils/bytes';import * as Dialog from '$lib/components/ui/dialog/index.js';import { displaySize, FileDropZone, MEGABYTE, type FileDropZoneProps } from '$lib/components/ui/file-drop-zone';import ImageTable from './image-table.svelte';diff --git a/frontend/src/routes/(app)/images/[imageId]/+page.svelte b/frontend/src/routes/(app)/images/[imageId]/+page.svelteindex aceecc562..da6d89967 100644--- a/frontend/src/routes/(app)/images/[imageId]/+page.svelte+++ b/frontend/src/routes/(app)/images/[imageId]/+page.svelte@@ -3,7 +3,7 @@import { goto } from '$app/navigation';import { Badge } from '$lib/components/ui/badge';import { format } from 'date-fns';- import bytes from 'bytes';+ import bytes from '$lib/utils/bytes';import { openConfirmDialog } from '$lib/components/confirm-dialog';import { handleApiResultWithCallbacks } from '$lib/utils/api.util';import { tryCatch } from '$lib/utils/try-catch';diff --git a/frontend/src/routes/(app)/images/image-table.svelte b/frontend/src/routes/(app)/images/image-table.svelteindex 611dd8a3b..3f1b0c29e 100644--- a/frontend/src/routes/(app)/images/image-table.svelte+++ b/frontend/src/routes/(app)/images/image-table.svelte@@ -6,7 +6,7 @@import { goto } from '$app/navigation';import { onDestroy } from 'svelte';import { toast } from 'svelte-sonner';- import bytes from 'bytes';+ import bytes from '$lib/utils/bytes';import { openConfirmDialog } from '$lib/components/confirm-dialog';import StatusBadge from '$lib/components/badges/status-badge.svelte';import { Badge } from '$lib/components/ui/badge/index.js';diff --git a/frontend/src/routes/(app)/volumes/components/volume-backup-table.svelte b/frontend/src/routes/(app)/volumes/components/volume-backup-table.svelteindex f09cf5181..0a1b36651 100644--- a/frontend/src/routes/(app)/volumes/components/volume-backup-table.svelte+++ b/frontend/src/routes/(app)/volumes/components/volume-backup-table.svelte@@ -19,7 +19,7 @@import { ArcaneButton } from '$lib/components/arcane-button';import { toast } from 'svelte-sonner';import * as m from '$lib/paraglide/messages.js';- import bytes from 'bytes';+ import bytes from '$lib/utils/bytes';import { format } from 'date-fns';import ArcaneTable from '$lib/components/arcane-table/arcane-table.svelte';import type { SearchPaginationSortRequest } from '$lib/types/pagination.type';diff --git a/frontend/src/routes/(app)/volumes/volume-table.svelte b/frontend/src/routes/(app)/volumes/volume-table.svelteindex 160202009..b1e39f7e6 100644--- a/frontend/src/routes/(app)/volumes/volume-table.svelte+++ b/frontend/src/routes/(app)/volumes/volume-table.svelte@@ -16,7 +16,7 @@import { UniversalMobileCard } from '$lib/components/arcane-table/index.js';import { m } from '$lib/paraglide/messages';import { volumeService } from '$lib/services/volume-service';- import bytes from 'bytes';+ import bytes from '$lib/utils/bytes';import { TrashIcon, InspectIcon, VolumesIcon, CalendarIcon, EllipsisIcon } from '$lib/icons';import { Spinner } from '$lib/components/ui/spinner';import settingsStore from '$lib/stores/config-store';diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 4a0592997..1fc35e8a9 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -140,9 +140,6 @@ importers:'@tanstack/svelte-query-devtools':specifier: ^6.0.4- '@types/bytes':- specifier: ^3.1.5- version: 3.1.5'@types/js-yaml':specifier: ^4.0.9version: 4.0.9@@ -152,9 +149,6 @@ importers:bits-ui:specifier: ^2.15.5version: 2.15.5(@internationalized/[email protected])(@sveltejs/[email protected](@sveltejs/[email protected]([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])))([email protected])- bytes:- specifier: ^3.1.2- version: 3.1.2clsx:specifier: ^2.1.1version: 2.1.1@@ -2025,9 +2019,6 @@ packages:'@tybys/[email protected]':resolution: {integrity: sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==}- '@types/[email protected]':- resolution: {integrity: sha512-VgZkrJckypj85YxEsEavcMmmSOIzkUHqWmM4CCyia5dc54YwsXzJ5uT4fYxBQNEXx+oF1krlhgCbvfubXqZYsQ==}-'@types/[email protected]':resolution: {integrity: sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==}@@ -2266,10 +2257,6 @@ packages:resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}- resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==}- engines: {node: '>= 0.8'}-resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==}engines: {node: '>= 0.4'}@@ -5519,8 +5506,6 @@ snapshots:tslib: 2.8.1optional: true- '@types/[email protected]': {}-'@types/[email protected]': {}'@types/[email protected]':@@ -5779,8 +5764,6 @@ snapshots:optional: true- [email protected]: {}-dependencies:es-errors: 1.3.0