feat: enable stricter type checking options

feat: make the app more fault tolerant
This commit is contained in:
2024-04-06 14:28:23 +02:00
parent bef51d2a7d
commit 2808973ad0
38 changed files with 152 additions and 121 deletions

View File

@@ -23,16 +23,6 @@
powerDialog = false;
}
async function updateFirmware() {
const { usbVendorId: vendorId, usbProductId: productId } =
$serialPort!.portInfo;
$serialPort!.bootloader();
await new Promise((resolve) => setTimeout(resolve, 1000));
console.log(
await navigator.usb.requestDevice({ filters: [{ vendorId, productId }] }),
);
}
let rebootInfo = false;
let terminal = false;
let powerDialog = false;

View File

@@ -32,12 +32,13 @@
}
function redo() {
const [change, ...queue] = redoQueue;
changes.update((it) => {
it.push(change);
return it;
});
redoQueue = queue;
const change = redoQueue.shift();
if (change) {
changes.update((it) => {
it.push(change);
return it;
});
}
}
let redoQueue: Change[] = [];
@@ -57,7 +58,7 @@
$LL.configure.chords.conflict.TITLE(),
$LL.configure.chords.conflict.DESCRIPTION(
actions
.map((it) => `<kbd>${KEYMAP_CODES[it].id}</kbd>`)
.map((it) => `<kbd>${KEYMAP_CODES.get(it)?.id}</kbd>`)
.join(" "),
),
$LL.configure.chords.conflict.CONFIRM(),

View File

@@ -68,6 +68,7 @@
{/if}
<SyncOverlay />
</div>
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
<ul>
<li class="hide-forced-colors">
<input

View File

@@ -37,7 +37,7 @@
index.add(
i,
chord.phrase
.map((it) => KEYMAP_CODES[it]?.id)
.map((it) => KEYMAP_CODES.get(it)?.id)
.filter((it) => !!it)
.join(""),
);
@@ -51,7 +51,9 @@
function search(event: Event) {
const query = (event.target as HTMLInputElement).value;
searchFilter.set(
query && searchIndex ? searchIndex.search(query) : undefined,
query && searchIndex
? (searchIndex.search(query) as number[])
: undefined,
);
page = 0;
}
@@ -131,10 +133,12 @@
>
{/if}
{#if $lastPage !== -1}
{#each $items.slice(page * $pageSize - (page === 0 ? 0 : 1), (page + 1) * $pageSize - 1) as [chord] (JSON.stringify(chord.id))}
<tr>
<ChordEdit {chord} />
</tr>
{#each $items.slice(page * $pageSize - (page === 0 ? 0 : 1), (page + 1) * $pageSize - 1) as [chord] (JSON.stringify(chord?.id))}
{#if chord}
<tr>
<ChordEdit {chord} />
</tr>
{/if}
{/each}
{:else}
<caption>{$LL.configure.chords.search.NO_RESULTS()}</caption>

View File

@@ -51,6 +51,7 @@
});
return changes;
});
return undefined;
}
function addSpecial(event: MouseEvent) {

View File

@@ -59,7 +59,7 @@
onHidden(instance) {
instance.destroy();
},
onDestroy(instance) {
onDestroy(_instance) {
shareComponent.$destroy();
},
}).show();

View File

@@ -1,3 +1,4 @@
// @ts-nocheck
/*******************************
* HOLD UP AND READ THIS FIRST *
*******************************

View File

@@ -1,4 +1,5 @@
<script>
// @ts-nocheck
let ongoingRequest;
let resolveRequest;
let source;

View File

@@ -48,18 +48,18 @@
if (next.length === 0) {
next = Array.from(
{ length: 5 },
() => $chords[Math.floor(Math.random() * $chords.length)],
() => $chords[Math.floor(Math.random() * $chords.length)]!,
);
} else {
next.shift();
next.push($chords[Math.floor(Math.random() * $chords.length)]);
next.push($chords[Math.floor(Math.random() * $chords.length)]!);
next = next;
}
}
if (
userInput ===
next[0].phrase
.map((it) => (it === 32 ? " " : KEYMAP_CODES[it]!.id))
next[0]!.phrase
.map((it) => (it === 32 ? " " : KEYMAP_CODES.get(it)!.id))
.join("") +
" "
) {