fix: patch flexsearch type definitions

[deploy]
This commit is contained in:
2023-07-28 18:54:02 +02:00
parent c709878d6a
commit e508d1312e
7 changed files with 422 additions and 4 deletions

4
src/lib/search-engine.ts Normal file
View File

@@ -0,0 +1,4 @@
import type {Index} from "flexsearch"
import FlexSearch from "flexsearch"
export function createIndex() {}

View File

@@ -1,5 +1,6 @@
<script>
import {theme} from "$lib/preferences"
import {tick} from "svelte"
</script>
<section>
@@ -7,7 +8,10 @@
<button
class="icon"
on:click={() => {
$theme.mode = $theme.mode === "light" ? "dark" : "light"
document.startViewTransition(async () => {
$theme.mode = $theme.mode === "light" ? "dark" : "light"
await tick()
})
}}
>
{#if $theme.mode === "light"}

View File

@@ -1,8 +1,7 @@
<script lang="ts">
import {chords} from "$lib/serial/connection"
import {KEYMAP_CODES} from "$lib/serial/keymap-codes"
import FlexSearch from "flexsearch"
import type {Index} from "flexsearch"
import Index from "flexsearch"
import {tick} from "svelte"
import type {Chord} from "$lib/serial/chord"
import tippy from "tippy.js"
@@ -13,7 +12,7 @@
$: searchIndex = $chords?.length > 0 ? buildIndex($chords) : undefined
function buildIndex(chords: Chord[]): Index {
const index = new FlexSearch({tokenize: "full"})
const index = new Index({tokenize: "full"})
chords.forEach((chord, i) => {
index.add(i, chord.phrase.map(it => KEYMAP_CODES[it].id).join(""))
})