mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-10 03:52:57 +00:00
fix: patch flexsearch type definitions
[deploy]
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Compress JSON.stringify with gzip
|
||||
*/
|
||||
export async function stringifyCompressed(chords: any): Promise<Blob> {
|
||||
export async function stringifyCompressed<T>(chords: T): Promise<Blob> {
|
||||
const stream = new Blob([JSON.stringify(chords)]).stream().pipeThrough(new CompressionStream("gzip"))
|
||||
return await new Response(stream).blob()
|
||||
}
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
<script lang="ts">
|
||||
import {getSharableUrl, parseCompressed, stringifyCompressed} from "$lib/serial/serialization"
|
||||
import {chords, layout} from "$lib/serial/connection"
|
||||
import type {Chord} from "$lib/serial/chord"
|
||||
import type {CharaLayout} from "$lib/serialization/layout"
|
||||
|
||||
interface CharaBackup {
|
||||
isCharaBackup: "v1.0"
|
||||
chords: Chord[]
|
||||
layout: CharaLayout
|
||||
}
|
||||
|
||||
async function downloadBackup() {
|
||||
const downloadUrl = URL.createObjectURL(
|
||||
await stringifyCompressed({
|
||||
await stringifyCompressed<CharaBackup>({
|
||||
isCharaBackup: "v1.0",
|
||||
chords: $chords,
|
||||
layout: $layout,
|
||||
@@ -18,10 +26,10 @@
|
||||
URL.revokeObjectURL(downloadUrl)
|
||||
}
|
||||
|
||||
async function restoreBackup(event: InputEvent) {
|
||||
async function restoreBackup(event: Event) {
|
||||
const input = (event.target as HTMLInputElement).files![0]
|
||||
if (!input) return
|
||||
const backup = await parseCompressed(input)
|
||||
const backup = await parseCompressed<CharaBackup>(input)
|
||||
if (backup.isCharaBackup !== "v1.0") throw new Error("Invalid Backup")
|
||||
if (backup.chords) {
|
||||
$chords = backup.chords
|
||||
@@ -91,10 +99,10 @@
|
||||
border-radius: 32px;
|
||||
|
||||
transition: all 250ms ease;
|
||||
}
|
||||
|
||||
&.primary {
|
||||
color: var(--md-sys-color-on-primary);
|
||||
background: var(--md-sys-color-primary);
|
||||
}
|
||||
button.primary {
|
||||
color: var(--md-sys-color-on-primary);
|
||||
background: var(--md-sys-color-primary);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -21,16 +21,16 @@
|
||||
|
||||
let searchFilter: number[] | undefined
|
||||
|
||||
function search(event) {
|
||||
function search(event: Event) {
|
||||
document.startViewTransition(async () => {
|
||||
const query = event.target.value
|
||||
const query = (event.target as HTMLInputElement).value
|
||||
searchFilter = query && searchIndex ? searchIndex.search(query) : undefined
|
||||
await tick()
|
||||
})
|
||||
}
|
||||
|
||||
const sort: MouseEventHandler<HTMLButtonElement> = function (event) {
|
||||
tippy(event.target, {})
|
||||
function sort(event: Event) {
|
||||
tippy(event.target as HTMLInputElement, {})
|
||||
}
|
||||
|
||||
$: items = searchFilter?.map(it => [$chords[it], it] as const) ?? $chords.map((it, i) => [it, i] as const)
|
||||
|
||||
Reference in New Issue
Block a user