mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-09-02 08:42:31 +00:00
fix typings
This commit is contained in:
@@ -10,8 +10,9 @@
|
|||||||
|
|
||||||
import { _ } from 'svelte-i18n';
|
import { _ } from 'svelte-i18n';
|
||||||
import type { GPXFile } from 'gpx';
|
import type { GPXFile } from 'gpx';
|
||||||
|
import type { FreezedObject } from 'structurajs';
|
||||||
|
|
||||||
export let file: Readable<GPXFile | undefined>;
|
export let file: Readable<FreezedObject<GPXFile> | undefined>;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||||
|
@@ -8,11 +8,12 @@ import { toast } from "svelte-sonner";
|
|||||||
|
|
||||||
import { _ } from "svelte-i18n";
|
import { _ } from "svelte-i18n";
|
||||||
import { dbUtils } from "$lib/db";
|
import { dbUtils } from "$lib/db";
|
||||||
|
import type { FreezedObject } from "structurajs";
|
||||||
|
|
||||||
export class RoutingControls {
|
export class RoutingControls {
|
||||||
map: mapboxgl.Map;
|
map: mapboxgl.Map;
|
||||||
fileId: string = '';
|
fileId: string = '';
|
||||||
file: Readable<GPXFile | undefined>;
|
file: Readable<FreezedObject<GPXFile> | undefined>;
|
||||||
anchors: AnchorWithMarker[] = [];
|
anchors: AnchorWithMarker[] = [];
|
||||||
shownAnchors: AnchorWithMarker[] = [];
|
shownAnchors: AnchorWithMarker[] = [];
|
||||||
popup: mapboxgl.Popup;
|
popup: mapboxgl.Popup;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import Dexie, { liveQuery } from 'dexie';
|
import Dexie, { liveQuery } from 'dexie';
|
||||||
import { GPXFile } from 'gpx';
|
import { GPXFile } from 'gpx';
|
||||||
import { type FreezedObject, type Patch, produceWithPatches, applyPatches } from 'structurajs';
|
import { type FreezedObject, type Patch, produceWithPatches, applyPatches, freeze } from 'structurajs';
|
||||||
import { writable, get, derived, type Readable, type Writable } from 'svelte/store';
|
import { writable, get, derived, type Readable, type Writable } from 'svelte/store';
|
||||||
import { fileOrder, selectedFiles } from './stores';
|
import { fileOrder, selectedFiles } from './stores';
|
||||||
|
|
||||||
@@ -27,17 +27,19 @@ class Database extends Dexie {
|
|||||||
|
|
||||||
const db = new Database();
|
const db = new Database();
|
||||||
|
|
||||||
function dexieFileStore(querier: () => FreezedObject<GPXFile> | undefined | Promise<FreezedObject<GPXFile> | undefined>): Readable<GPXFile> {
|
function dexieFileStore(querier: () => FreezedObject<GPXFile> | undefined | Promise<FreezedObject<GPXFile> | undefined>): Writable<FreezedObject<GPXFile>> {
|
||||||
let store = writable<GPXFile>(undefined);
|
let store = writable<FreezedObject<GPXFile>>(undefined);
|
||||||
liveQuery(querier).subscribe(value => {
|
liveQuery(querier).subscribe(value => {
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
let gpx = new GPXFile(value);
|
let gpx = freeze(new GPXFile(value));
|
||||||
fileState.set(gpx._data.id, gpx);
|
fileState.set(gpx._data.id, gpx);
|
||||||
store.set(gpx);
|
store.set(gpx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
subscribe: store.subscribe,
|
subscribe: store.subscribe,
|
||||||
|
update: store.update,
|
||||||
|
set: store.set
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,8 +85,8 @@ function commitFileStateChange(newFileState: ReadonlyMap<string, FreezedObject<G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fileObservers: Writable<Map<string, Readable<GPXFile | undefined>>> = writable(new Map());
|
export const fileObservers: Writable<Map<string, Writable<FreezedObject<GPXFile> | undefined>>> = writable(new Map());
|
||||||
const fileState: Map<string, GPXFile> = new Map(); // Used to generate patches
|
const fileState: Map<string, FreezedObject<GPXFile>> = new Map(); // Used to generate patches
|
||||||
|
|
||||||
liveQuery(() => db.fileids.toArray()).subscribe(dbFileIds => {
|
liveQuery(() => db.fileids.toArray()).subscribe(dbFileIds => {
|
||||||
// Find new files to observe
|
// Find new files to observe
|
||||||
|
@@ -6,6 +6,7 @@ import { tick } from 'svelte';
|
|||||||
import { _ } from 'svelte-i18n';
|
import { _ } from 'svelte-i18n';
|
||||||
import type { GPXLayer } from '$lib/components/gpx-layer/GPXLayer';
|
import type { GPXLayer } from '$lib/components/gpx-layer/GPXLayer';
|
||||||
import { dbUtils, fileObservers } from './db';
|
import { dbUtils, fileObservers } from './db';
|
||||||
|
import type { FreezedObject } from 'structurajs';
|
||||||
|
|
||||||
export const map = writable<mapboxgl.Map | null>(null);
|
export const map = writable<mapboxgl.Map | null>(null);
|
||||||
|
|
||||||
@@ -192,7 +193,7 @@ export function exportAllFiles() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function exportFile(file: GPXFile) {
|
export function exportFile(file: FreezedObject<GPXFile>) {
|
||||||
let blob = new Blob([buildGPX(file)], { type: 'application/gpx+xml' });
|
let blob = new Blob([buildGPX(file)], { type: 'application/gpx+xml' });
|
||||||
let url = URL.createObjectURL(blob);
|
let url = URL.createObjectURL(blob);
|
||||||
let a = document.createElement('a');
|
let a = document.createElement('a');
|
||||||
|
Reference in New Issue
Block a user