This commit is contained in:
2023-07-07 12:45:21 +02:00
parent d63cf541fb
commit bb3861272c
11 changed files with 177 additions and 48 deletions

View File

@@ -1,4 +1,11 @@
export default {
export interface IconsConfig {
codePoints: Record<string, string>
inputPath: string
outputPath: string
icons: string[]
}
const config: IconsConfig = {
inputPath:
"node_modules/@fontsource-variable/material-symbols-rounded/files/material-symbols-rounded-latin-full-normal.woff2",
outputPath: "src/lib/assets/icons.min.woff2",
@@ -28,3 +35,5 @@ export default {
speed: "e9e4",
},
}
export default config

141
package-lock.json generated
View File

@@ -30,6 +30,7 @@
"svelte": "^4.0.0",
"svelte-check": "^3.4.3",
"svelte-preprocess": "^5.0.4",
"ts-node": "^10.9.1",
"typescript": "^5.0.0",
"vite": "^4.3.6",
"vite-plugin-pwa": "^0.16.4"
@@ -1746,6 +1747,28 @@
"node": ">=6.9.0"
}
},
"node_modules/@cspotcode/source-map-support": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
"integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
"dev": true,
"dependencies": {
"@jridgewell/trace-mapping": "0.3.9"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": {
"version": "0.3.9",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
"integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
"dev": true,
"dependencies": {
"@jridgewell/resolve-uri": "^3.0.3",
"@jridgewell/sourcemap-codec": "^1.4.10"
}
},
"node_modules/@csstools/css-parser-algorithms": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-2.2.0.tgz",
@@ -2419,6 +2442,30 @@
"integrity": "sha512-DdP5OvUL6Tso+XMNiH+WQJrbvJsIGIudekZKMW4oGt060hqZIzwiASILCiDg6+OigKTC1KObvv4nTBQSjM2g1g==",
"dev": true
},
"node_modules/@tsconfig/node10": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz",
"integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==",
"dev": true
},
"node_modules/@tsconfig/node12": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz",
"integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==",
"dev": true
},
"node_modules/@tsconfig/node14": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz",
"integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==",
"dev": true
},
"node_modules/@tsconfig/node16": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz",
"integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==",
"dev": true
},
"node_modules/@types/cookie": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.5.1.tgz",
@@ -2504,6 +2551,15 @@
"node": ">=0.4.0"
}
},
"node_modules/acorn-walk": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",
"dev": true,
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/ajv": {
"version": "8.12.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",
@@ -2554,6 +2610,12 @@
"node": ">= 8"
}
},
"node_modules/arg": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
"dev": true
},
"node_modules/argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
@@ -3073,6 +3135,12 @@
"url": "https://github.com/sponsors/d-fischer"
}
},
"node_modules/create-require": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
"dev": true
},
"node_modules/crypto-random-string": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz",
@@ -3222,6 +3290,15 @@
"integrity": "sha512-ED3jP8saaweFTjeGX8HQPjeC1YYyZs98jGNZx6IiBvxW7JG5v492kamAQB3m2wop07CvU/RQmzcKr6bgcC5D/Q==",
"dev": true
},
"node_modules/diff": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
"dev": true,
"engines": {
"node": ">=0.3.1"
}
},
"node_modules/dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
@@ -4799,6 +4876,12 @@
"node": ">=12"
}
},
"node_modules/make-error": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
"dev": true
},
"node_modules/map-obj": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/map-obj/-/map-obj-4.3.0.tgz",
@@ -6674,6 +6757,49 @@
"node": ">=8"
}
},
"node_modules/ts-node": {
"version": "10.9.1",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz",
"integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==",
"dev": true,
"dependencies": {
"@cspotcode/source-map-support": "^0.8.0",
"@tsconfig/node10": "^1.0.7",
"@tsconfig/node12": "^1.0.7",
"@tsconfig/node14": "^1.0.0",
"@tsconfig/node16": "^1.0.2",
"acorn": "^8.4.1",
"acorn-walk": "^8.1.1",
"arg": "^4.1.0",
"create-require": "^1.1.0",
"diff": "^4.0.1",
"make-error": "^1.1.1",
"v8-compile-cache-lib": "^3.0.1",
"yn": "3.1.1"
},
"bin": {
"ts-node": "dist/bin.js",
"ts-node-cwd": "dist/bin-cwd.js",
"ts-node-esm": "dist/bin-esm.js",
"ts-node-script": "dist/bin-script.js",
"ts-node-transpile-only": "dist/bin-transpile.js",
"ts-script": "dist/bin-script-deprecated.js"
},
"peerDependencies": {
"@swc/core": ">=1.2.50",
"@swc/wasm": ">=1.2.50",
"@types/node": "*",
"typescript": ">=2.7"
},
"peerDependenciesMeta": {
"@swc/core": {
"optional": true
},
"@swc/wasm": {
"optional": true
}
}
},
"node_modules/tslib": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.0.tgz",
@@ -6882,6 +7008,12 @@
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
"dev": true
},
"node_modules/v8-compile-cache-lib": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
"integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==",
"dev": true
},
"node_modules/validate-npm-package-license": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
@@ -7404,6 +7536,15 @@
"engines": {
"node": ">=10"
}
},
"node_modules/yn": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
"integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
"dev": true,
"engines": {
"node": ">=6"
}
}
}
}

View File

@@ -8,7 +8,7 @@
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
"minify-icons": "node tools/minify-icon-font.js",
"minify-icons": "ts-node-esm tools/minify-icon-font.ts",
"lint": "prettier --plugin-search-dir . --check .",
"format": "prettier --plugin-search-dir . --write ."
},
@@ -32,6 +32,7 @@
"prettier-plugin-svelte": "^2.10.1",
"svelte": "^4.0.0",
"svelte-check": "^3.4.3",
"ts-node": "^10.9.1",
"typescript": "^5.0.0",
"vite": "^4.3.6",
"vite-plugin-pwa": "^0.16.4",

View File

@@ -106,7 +106,6 @@
clip-path: polygon(25% 50%, 0% 0%, 75% 0%, 100% 50%, 75% 100%, 0% 100%);
border-radius: 0;
&.active,
&:active {
color: var(--md-sys-color-on-tertiary);
background: var(--md-sys-color-tertiary);

View File

@@ -20,7 +20,10 @@
}
function getKeyDescriptions(keys: KeyInfo[]): string {
return keys.map(({title, id, code}, i) => `${title || id || code} (${layerNames[i]})`).join("\n")
return keys
.filter(it => !!it)
.map(({title, id, code}, i) => `${title || id || code} (${layerNames[i]})`)
.join("\n")
}
function getActions(id: number, layout: CharaLayout): KeyInfo[] {
@@ -35,11 +38,12 @@
{#each [keys.n, keys.e, keys.s, keys.w] as id, quadrant}
{@const actions = getActions(id, $layout)}
<button title={getKeyDescriptions(actions)}>
{#each actions as { symbol, id }, layer}
{#if symbol || id}
{#each actions as keyInfo, layer}
{@const displayTitle = keyInfo?.symbol || keyInfo?.id}
{#if displayTitle}
<span
class:active={virtualLayerMap[activeLayer] === virtualLayerMap[layer]}
style="offset-distance: {offsetDistance(quadrant, layer, activeLayer)}%">{symbol || id}</span
style="offset-distance: {offsetDistance(quadrant, layer, activeLayer)}%">{displayTitle}</span
>
{/if}
{/each}

View File

@@ -11,12 +11,10 @@
let value: string
let io: HTMLDivElement
export let resizable = false
</script>
<form on:submit={submit}>
<div bind:this={io} class="io" class:resizable>
<div bind:this={io} class="io">
{#each $serialLog as { type, value }}
<p class={type} transition:slide>{value}</p>
{/each}
@@ -44,10 +42,6 @@
color: var(--md-sys-color-on-secondary);
border-radius: 16px;
&.resizable {
resize: both;
}
}
::-webkit-scrollbar {
@@ -125,21 +119,6 @@
}
}
.terminal.resizable fieldset::after {
content: "";
position: absolute;
right: 6px;
bottom: 8px;
rotate: -45deg;
width: 10px;
height: 5px;
background: var(--md-sys-color-on-secondary);
clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.anchor {
overflow-anchor: auto;
height: 1px;

View File

@@ -15,8 +15,12 @@
<th>{phrase}</th>
<td>
{#each actions as action}
{@const {id, title, symbol} = KEYMAP_CODES[action]}
<abbr {title}>{symbol || id}</abbr>
{@const keyInfo = KEYMAP_CODES[action]}
{#if keyInfo}
<abbr title={keyInfo.title}>{keyInfo.symbol || keyInfo.id}</abbr>
{:else}
<pre>{action}</pre>
{/if}
{/each}
</td>
</tr>

View File

@@ -1,5 +1,5 @@
<script>
import {initSerial, serialPort} from "$lib/serial/connection.js"
import {initSerial, serialPort} from "$lib/serial/connection"
import Terminal from "$lib/components/Terminal.svelte"
import {browser} from "$app/environment"
</script>

View File

@@ -12,18 +12,13 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* eslint-disable @typescript-eslint/no-non-null-assertion */
// @ts-expect-error missing types
import {openSync} from "fontkit"
import {exec} from "child_process"
import config from "../icons.config.js"
import config from "../../icons.config"
import {statSync, existsSync} from "fs"
/**
* @param command {string[] | string}
* @returns {Promise<string>}
*/
async function run(command) {
async function run(command: string[] | string): Promise<string> {
const fullCommand = Array.isArray(command) ? command.join(" ") : command
console.log(`>> ${fullCommand}`)
@@ -40,7 +35,6 @@ async function run(command) {
})
}
/** @type {Set<string>} */
const icons = new Set(config.icons)
console.log("Icons used:", [...icons.values()].sort())
@@ -48,7 +42,7 @@ const font = openSync(config.inputPath)
const glyphs = ["5f-7a", "30-39"]
for (const icon of icons) {
const iconGlyphs = font.layout(icon).glyphs
const iconGlyphs: Array<{id: string}> = font.layout(icon).glyphs
if (iconGlyphs.length === 0) {
console.error(`${icon} not found in font. Typo?`)
process.exit(-1)
@@ -60,6 +54,7 @@ for (const icon of icons) {
.map(it => it.codePointAt(0).toString(16))
if (codePoints.length === 0) {
const codePoint = config.codePoints[icon]
if (config.codePoints?.[icon]) {
glyphs.push(config.codePoints[icon])
} else {
@@ -103,11 +98,8 @@ console.log(
/**
* Bytes to respective units
*
* @param value {number}
* @returns {string}
*/
function toByteUnit(value) {
function toByteUnit(value: number) {
if (value < 1024) {
return `${value}B`
} else if (value < 1024 * 1024) {

View File

@@ -1,8 +1,8 @@
import {sveltekit} from "@sveltejs/kit/vite"
import {defineConfig} from "vite"
import {SvelteKitPWA} from "@vite-pwa/sveltekit"
// noinspection ES6PreferShortImport
import {themeColor} from "./src/lib/style/theme.server.js"
import {themeColor} from "./src/lib/style/theme.server"
import {sveltekit} from "@sveltejs/kit/vite"
export default defineConfig({
plugins: [