mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-07 02:22:52 +00:00
fix: patch flexsearch type definitions
[deploy]
This commit is contained in:
4
src/lib/search-engine.ts
Normal file
4
src/lib/search-engine.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import type {Index} from "flexsearch"
|
||||
import FlexSearch from "flexsearch"
|
||||
|
||||
export function createIndex() {}
|
||||
@@ -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"}
|
||||
|
||||
@@ -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(""))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user