mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-02-27 11:32:05 +00:00
fix: patch flexsearch type definitions
[deploy]
This commit is contained in:
1
package-lock.json
generated
1
package-lock.json
generated
@@ -7,6 +7,7 @@
|
|||||||
"": {
|
"": {
|
||||||
"name": "amacc1ng",
|
"name": "amacc1ng",
|
||||||
"version": "0.3.0",
|
"version": "0.3.0",
|
||||||
|
"hasInstallScript": true,
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@fontsource-variable/material-symbols-rounded": "^5.0.4",
|
"@fontsource-variable/material-symbols-rounded": "^5.0.4",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"build": "typesafe-i18n --no-watch && vite build",
|
"build": "typesafe-i18n --no-watch && vite build",
|
||||||
"test": "vitest run --coverage",
|
"test": "vitest run --coverage",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
|
"postinstall": "patch-package",
|
||||||
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
|
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
|
||||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
|
||||||
"minify-icons": "ts-node-esm src/tools/minify-icon-font.ts",
|
"minify-icons": "ts-node-esm src/tools/minify-icon-font.ts",
|
||||||
|
|||||||
@@ -1,13 +1,21 @@
|
|||||||
diff --git a/node_modules/@types/flexsearch/index.d.ts b/node_modules/@types/flexsearch/index.d.ts
|
diff --git a/node_modules/@types/flexsearch/index.d.ts b/node_modules/@types/flexsearch/index.d.ts
|
||||||
index ecde8e7..4173464 100755
|
index ecde8e7..64a5f1e 100755
|
||||||
--- a/node_modules/@types/flexsearch/index.d.ts
|
--- a/node_modules/@types/flexsearch/index.d.ts
|
||||||
+++ b/node_modules/@types/flexsearch/index.d.ts
|
+++ b/node_modules/@types/flexsearch/index.d.ts
|
||||||
@@ -165,7 +165,7 @@ export type IndexSearchResult = Id[];
|
@@ -6,7 +6,6 @@
|
||||||
|
/************************************/
|
||||||
|
/* Utils */
|
||||||
|
/************************************/
|
||||||
|
-export type Id = number | string;
|
||||||
|
export type Limit = number;
|
||||||
|
export type ExportHandler<T> = (id: string | number, value: T) => void;
|
||||||
|
export type AsyncCallback<T = undefined> = T extends undefined ? () => void : (result: T) => void;
|
||||||
|
@@ -165,7 +164,7 @@ export type IndexSearchResult = Id[];
|
||||||
* * Usage: https://github.com/nextapps-de/flexsearch#usage
|
* * Usage: https://github.com/nextapps-de/flexsearch#usage
|
||||||
*/
|
*/
|
||||||
|
|
||||||
-export class Index {
|
-export class Index {
|
||||||
+export default class Index {
|
+export default class Index<ID extends number | string = number> {
|
||||||
constructor(x?: Preset | IndexOptions<string>);
|
constructor(x?: Preset | IndexOptions<string>);
|
||||||
add(id: Id, item: string): this;
|
add(id: Id, item: string): this;
|
||||||
append(id: Id, item: string): this;
|
append(id: Id, item: string): this;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Compress JSON.stringify with gzip
|
* 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"))
|
const stream = new Blob([JSON.stringify(chords)]).stream().pipeThrough(new CompressionStream("gzip"))
|
||||||
return await new Response(stream).blob()
|
return await new Response(stream).blob()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {getSharableUrl, parseCompressed, stringifyCompressed} from "$lib/serial/serialization"
|
import {getSharableUrl, parseCompressed, stringifyCompressed} from "$lib/serial/serialization"
|
||||||
import {chords, layout} from "$lib/serial/connection"
|
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() {
|
async function downloadBackup() {
|
||||||
const downloadUrl = URL.createObjectURL(
|
const downloadUrl = URL.createObjectURL(
|
||||||
await stringifyCompressed({
|
await stringifyCompressed<CharaBackup>({
|
||||||
isCharaBackup: "v1.0",
|
isCharaBackup: "v1.0",
|
||||||
chords: $chords,
|
chords: $chords,
|
||||||
layout: $layout,
|
layout: $layout,
|
||||||
@@ -18,10 +26,10 @@
|
|||||||
URL.revokeObjectURL(downloadUrl)
|
URL.revokeObjectURL(downloadUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function restoreBackup(event: InputEvent) {
|
async function restoreBackup(event: Event) {
|
||||||
const input = (event.target as HTMLInputElement).files![0]
|
const input = (event.target as HTMLInputElement).files![0]
|
||||||
if (!input) return
|
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.isCharaBackup !== "v1.0") throw new Error("Invalid Backup")
|
||||||
if (backup.chords) {
|
if (backup.chords) {
|
||||||
$chords = backup.chords
|
$chords = backup.chords
|
||||||
@@ -91,10 +99,10 @@
|
|||||||
border-radius: 32px;
|
border-radius: 32px;
|
||||||
|
|
||||||
transition: all 250ms ease;
|
transition: all 250ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
&.primary {
|
button.primary {
|
||||||
color: var(--md-sys-color-on-primary);
|
color: var(--md-sys-color-on-primary);
|
||||||
background: var(--md-sys-color-primary);
|
background: var(--md-sys-color-primary);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -21,16 +21,16 @@
|
|||||||
|
|
||||||
let searchFilter: number[] | undefined
|
let searchFilter: number[] | undefined
|
||||||
|
|
||||||
function search(event) {
|
function search(event: Event) {
|
||||||
document.startViewTransition(async () => {
|
document.startViewTransition(async () => {
|
||||||
const query = event.target.value
|
const query = (event.target as HTMLInputElement).value
|
||||||
searchFilter = query && searchIndex ? searchIndex.search(query) : undefined
|
searchFilter = query && searchIndex ? searchIndex.search(query) : undefined
|
||||||
await tick()
|
await tick()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const sort: MouseEventHandler<HTMLButtonElement> = function (event) {
|
function sort(event: Event) {
|
||||||
tippy(event.target, {})
|
tippy(event.target as HTMLInputElement, {})
|
||||||
}
|
}
|
||||||
|
|
||||||
$: items = searchFilter?.map(it => [$chords[it], it] as const) ?? $chords.map((it, i) => [it, i] as const)
|
$: items = searchFilter?.map(it => [$chords[it], it] as const) ?? $chords.map((it, i) => [it, i] as const)
|
||||||
|
|||||||
Reference in New Issue
Block a user