Optimizing footprint

This commit is contained in:
Gunnar Skjold
2026-03-05 16:34:10 +01:00
parent d4f11c0412
commit 640e957065
5 changed files with 70 additions and 12 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -25,7 +25,6 @@
},
"dependencies": {
"cssnano": "^5.1.15",
"esbuild": ">=0.25.0",
"ipaddr.js": "^2.3.0"
"esbuild": ">=0.25.0"
}
}

View File

@@ -6,7 +6,6 @@
import Clock from '../lib/Clock.svelte';
import Mask from '../lib/Mask.svelte';
import { scanForDevice } from '../lib/Helpers.js';
import ipaddr from 'ipaddr.js';
let data;
let sysinfo;
@@ -14,6 +13,59 @@
dataStore.subscribe(v => data = v);
sysinfoStore.subscribe(v => sysinfo = v);
// Format IPv6 address to compact form (RFC 5952)
const formatIPv6 = (addr) => {
if (!addr) return addr;
// Split into groups
const groups = addr.toLowerCase().split(':');
// Remove leading zeros from each group
const normalized = groups.map(g => g.replace(/^0+/, '') || '0');
// Find longest sequence of consecutive zeros
let maxStart = -1, maxLen = 0;
let currStart = -1, currLen = 0;
for (let i = 0; i < normalized.length; i++) {
if (normalized[i] === '0') {
if (currStart === -1) currStart = i;
currLen++;
} else {
if (currLen > maxLen) {
maxStart = currStart;
maxLen = currLen;
}
currStart = -1;
currLen = 0;
}
}
// Check final sequence
if (currLen > maxLen) {
maxStart = currStart;
maxLen = currLen;
}
// Only compress if we have 2 or more consecutive zeros
if (maxLen > 1) {
const before = normalized.slice(0, maxStart);
const after = normalized.slice(maxStart + maxLen);
if (before.length === 0 && after.length === 0) {
return '::';
} else if (before.length === 0) {
return '::' + after.join(':');
} else if (after.length === 0) {
return before.join(':') + '::';
} else {
return before.join(':') + '::' + after.join(':');
}
}
return normalized.join(':');
};
let cfgItems = [{
name: 'WiFi',
key: 'iw'
@@ -210,11 +262,11 @@
</div>
{#if sysinfo.net.ipv6}
<div class="my-2">
IPv6: <span style="font-size: 14px;">{ipaddr.parse(sysinfo.net.ipv6)}</span>
IPv6: <span style="font-size: 14px;">{formatIPv6(sysinfo.net.ipv6)}</span>
</div>
<div class="my-2">
{#if sysinfo.net.dns1v6}DNSv6: <span style="font-size: 14px;">{ipaddr.parse(sysinfo.net.dns1v6)}</span>{/if}
{#if sysinfo.net.dns2v6}DNSv6: <span style="font-size: 14px;">{ipaddr.parse(sysinfo.net.dns2v6)}</span>{/if}
{#if sysinfo.net.dns1v6}DNSv6: <span style="font-size: 14px;">{formatIPv6(sysinfo.net.dns1v6)}</span>{/if}
{#if sysinfo.net.dns2v6}DNSv6: <span style="font-size: 14px;">{formatIPv6(sysinfo.net.dns2v6)}</span>{/if}
</div>
{/if}
</div>

View File

@@ -6,15 +6,22 @@ export default defineConfig({
build: {
outDir: 'dist',
assetsDir: '.',
minify: 'esbuild',
target: 'es2020',
rollupOptions: {
output: {
assetFileNames: '[name][extname]',
chunkFileNames: '[name].js',
entryFileNames: '[name].js'
entryFileNames: '[name].js',
manualChunks: undefined
}
}
},
plugins: [svelte()],
plugins: [svelte({
compilerOptions: {
dev: false
}
})],
server: {
proxy: {
"/data.json": "http://192.168.21.122",