mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-12-06 10:34:13 +00:00
Migration to new Rust-based engine (#401)
* wasm first steps * parsing start * parsing continued * progress * progress * progress * progress * progress * progress * progress * progress * fixes * reorganize * change type * fix * progress * refactoring * progress * progress * progress * keep style info * progress * progress * remove (copy) in name * progress * merge methods into 1 * splice * progress * progress * progress * cleaning * progress * progress * progress * visibility * progress * progress * progress * progress * progress * fixes * progress * fix markers * fix * progress * progress * progress * progress * progress * progress * small fix * use engine info * fix popups * small fix * progress * progress * progress * clean tool * handle self closing elements * reduce data exchanges across boundary * copy on wasm side to avoid any data corruption * speed fix * routing * refactoring * reverse * reverse * crop * split * merge * progress * time tool * fix bounds for waypoints * reduce * fix reactivity * handle corrupt time data * export * progress * remove gpx js package * remove todo * update readme * cleaning * progress * fix link fields * remove unused fields * refactoring and tests * import and export of routes, ref #192 * per-chunk categories storage * cross-tab sync * outdated state * refactoring * reorder methods * refactoring * fix * improve flow * renaming * progress * progress * fix * progress * per file history * keep original flag * use history variant * fix * progress * file explorer * progress * fix * sticky folders * improved sticky folders * fix sortable * fix sortable * fix * fix tab size * no file delete on desktop * fix routing on other file * fix sorting * remember language * open links in browser * commit missing changes * avoid selecting on resize * clarify filename * explorer actions * fix folder styling * drop anywhere in folder * cleaning * fixes * remove focus-ring * full screen * small fix * consistent highlight color * improved preview * performance improvements * sparser data transfers * sparser data transfers * show popup once data is loaded * fix routing control size * fix * sparse desktop build * remove custom ign styles * use new endpoint for openhikingmap * strip native menu * reorder context menu items * route full support * route - track conversion * create route file action * route export, filter out anchors at high zoom level * clarify name handling * move hide & center to view * routes continued * update docs * fix power format, closes #378 * lint fixes * fix display of additional data with gaps, closes #361 * fix linting issues * fix import modules * fix multidrag * change base to resolve * fix type errors * fix layer typings * fix last type error * each keys * improve typings * deploy to cloudflare --------- Co-authored-by: vcoppe <vcoppe@hexaly.com>
This commit is contained in:
1 parent
6a0d434371
commit
8fe7d8d64d
484 files changed
+53949
-41152
No files matched your search
@@ -1,7 +1,9 @@
|
||||
<script lang="ts">
|
||||
import { resolve } from '$app/paths';
|
||||
import GPXLayers from '$lib/components/map/gpx-layer/GPXLayers.svelte';
|
||||
import ElevationProfile from '$lib/components/elevation-profile/ElevationProfile.svelte';
|
||||
import FileList from '$lib/components/file-list/FileList.svelte';
|
||||
import Explorer from '$lib/components/explorer/Explorer.svelte';
|
||||
import GPXStatistics from '$lib/components/GPXStatistics.svelte';
|
||||
import Map from '$lib/components/map/Map.svelte';
|
||||
import Menu from '$lib/components/Menu.svelte';
|
||||
@@ -11,57 +13,100 @@
|
||||
import CoordinatesPopup from '$lib/components/map/CoordinatesPopup.svelte';
|
||||
import Resizer from '$lib/components/Resizer.svelte';
|
||||
import { Toaster } from '$lib/components/ui/sonner';
|
||||
import { i18n } from '$lib/i18n.svelte';
|
||||
import { settings } from '$lib/logic/settings';
|
||||
import { loadFiles } from '$lib/logic/file-actions';
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
import * as AlertDialog from '$lib/components/ui/alert-dialog';
|
||||
import { i18n } from '$lib/i18n/i18n.svelte';
|
||||
import { settings } from '$lib/state/settings';
|
||||
import { loadFiles } from '$lib/actions/file-actions';
|
||||
import { onMount } from 'svelte';
|
||||
import { page } from '$app/state';
|
||||
import { gpxStatistics, hoveredPoint, slicedGPXStatistics } from '$lib/logic/statistics';
|
||||
import { goto } from '$app/navigation';
|
||||
import { get } from 'svelte/store';
|
||||
import { getURLForLanguage } from '$lib/utils';
|
||||
import { inDesktopApp } from '$lib/engine/backend';
|
||||
import { openLinksInBrowser } from '$lib/desktop/links';
|
||||
import { hoveredPoint, slicedStatistics } from '$lib/state/selection-statistics';
|
||||
import { engine } from '$lib/engine';
|
||||
import { boundsManager } from '$lib/state/bounds';
|
||||
import { getURLForGoogleDriveFile } from '$lib/components/embedding/embedding';
|
||||
import { db } from '$lib/db';
|
||||
import { fileStateCollection } from '$lib/logic/file-state';
|
||||
|
||||
const outdated = engine.outdated;
|
||||
const workspace = engine.workspace;
|
||||
|
||||
const {
|
||||
treeFileView,
|
||||
elevationProfile,
|
||||
bottomPanelSize,
|
||||
rightPanelSize,
|
||||
explorerPanelSize,
|
||||
additionalDatasets,
|
||||
elevationFill,
|
||||
} = settings;
|
||||
|
||||
let bottomPanelWidth: number | undefined = $state();
|
||||
// the file list and the explorer share the right panel, half of it each until it is resized
|
||||
let rightPanelHeight = $state(0);
|
||||
let explorerHeight = $derived(
|
||||
$treeFileView
|
||||
? Math.min(
|
||||
Math.max($explorerPanelSize > 0 ? $explorerPanelSize : rightPanelHeight / 2, 60),
|
||||
Math.max(rightPanelHeight - 80, 60)
|
||||
)
|
||||
: rightPanelHeight
|
||||
);
|
||||
let bottomPanelOrientation = $derived(
|
||||
bottomPanelWidth && bottomPanelWidth >= 540 && $elevationProfile ? 'horizontal' : 'vertical'
|
||||
);
|
||||
|
||||
onMount(async () => {
|
||||
settings.connectToDatabase(db);
|
||||
fileStateCollection.connectToDatabase(db).then(() => {
|
||||
let files: string[] = JSON.parse(page.url.searchParams.get('files') || '[]');
|
||||
let ids: string[] = JSON.parse(page.url.searchParams.get('ids') || '[]');
|
||||
let urls: string[] = files.concat(ids.map(getURLForGoogleDriveFile));
|
||||
// the language of the page, which is in its address (none for English)
|
||||
let language = $derived(page.params.language ?? 'en');
|
||||
// whether the language that was chosen last was gone back to (the desktop app)
|
||||
let languageRestored = $state(false);
|
||||
|
||||
if (urls.length > 0) {
|
||||
let downloads: Promise<File | null>[] = [];
|
||||
urls.forEach((url) => {
|
||||
downloads.push(
|
||||
fetch(url)
|
||||
.then((response) => response.blob())
|
||||
.then((blob) => new File([blob], url.split('/').pop() ?? ''))
|
||||
);
|
||||
});
|
||||
|
||||
Promise.all(downloads).then((files) => {
|
||||
loadFiles(files.filter((file) => file !== null));
|
||||
});
|
||||
}
|
||||
});
|
||||
$effect(() => {
|
||||
if (languageRestored) {
|
||||
settings.language.set(language);
|
||||
}
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
settings.disconnectFromDatabase();
|
||||
fileStateCollection.disconnectFromDatabase();
|
||||
onMount(async () => {
|
||||
// files that the system opens with the app while it runs
|
||||
engine.onFilesOpened((ids) => boundsManager.fitBoundsOnLoad(ids));
|
||||
settings.connect(await engine.openStorage());
|
||||
|
||||
if (inDesktopApp()) {
|
||||
openLinksInBrowser();
|
||||
// the window of the desktop app always opens the same page, in English: it goes to the
|
||||
// language that was chosen last
|
||||
const saved = get(settings.language);
|
||||
if (saved !== undefined && saved !== language) {
|
||||
await goto(
|
||||
resolve(
|
||||
`${getURLForLanguage(saved, page.url.pathname)}${page.url.search}${page.url.hash}`
|
||||
),
|
||||
{ replaceState: true }
|
||||
);
|
||||
}
|
||||
languageRestored = true;
|
||||
}
|
||||
|
||||
let files: string[] = JSON.parse(page.url.searchParams.get('files') || '[]');
|
||||
let ids: string[] = JSON.parse(page.url.searchParams.get('ids') || '[]');
|
||||
let urls: string[] = files.concat(ids.map(getURLForGoogleDriveFile));
|
||||
|
||||
if (urls.length > 0) {
|
||||
let downloads: Promise<File | null>[] = [];
|
||||
urls.forEach((url) => {
|
||||
downloads.push(
|
||||
fetch(url)
|
||||
.then((response) => response.blob())
|
||||
.then((blob) => new File([blob], url.split('/').pop() ?? ''))
|
||||
);
|
||||
});
|
||||
|
||||
Promise.all(downloads).then((files) => {
|
||||
loadFiles(files.filter((file) => file !== null));
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -118,7 +163,7 @@
|
||||
<CoordinatesPopup />
|
||||
<Toaster richColors />
|
||||
{#if !$treeFileView}
|
||||
<div class="h-10 -translate-y-10 w-full pointer-events-none absolute z-30">
|
||||
<div class="h-10 w-full pointer-events-none absolute bottom-0 left-0 z-30">
|
||||
<FileList orientation="horizontal" />
|
||||
</div>
|
||||
{/if}
|
||||
@@ -139,14 +184,14 @@
|
||||
style={$elevationProfile ? `height: ${$bottomPanelSize}px` : ''}
|
||||
>
|
||||
<GPXStatistics
|
||||
{gpxStatistics}
|
||||
{slicedGPXStatistics}
|
||||
statistics={engine.statistics}
|
||||
{slicedStatistics}
|
||||
orientation={bottomPanelOrientation == 'horizontal' ? 'vertical' : 'horizontal'}
|
||||
/>
|
||||
{#if $elevationProfile}
|
||||
<ElevationProfile
|
||||
{gpxStatistics}
|
||||
{slicedGPXStatistics}
|
||||
statistics={engine.statistics}
|
||||
{slicedStatistics}
|
||||
{hoveredPoint}
|
||||
{additionalDatasets}
|
||||
{elevationFill}
|
||||
@@ -154,12 +199,60 @@
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{#if $treeFileView}
|
||||
{#if $treeFileView || $workspace?.folder}
|
||||
<Resizer orientation="col" bind:after={$rightPanelSize} minAfter={100} maxAfter={400} />
|
||||
<FileList orientation="vertical" recursive={true} style="width: {$rightPanelSize}px" />
|
||||
<div
|
||||
bind:clientHeight={rightPanelHeight}
|
||||
class="flex flex-col h-full min-h-0 shrink-0"
|
||||
style="width: {$rightPanelSize}px"
|
||||
>
|
||||
{#if $treeFileView}
|
||||
{#if $workspace}
|
||||
<div class="px-2 py-1 text-sm font-semibold shrink-0">
|
||||
{i18n._('menu.workspace')}
|
||||
</div>
|
||||
{/if}
|
||||
<!-- a row, as the file list was: its scroll area is as high as this, whatever its content -->
|
||||
<div class="grow min-h-0 flex flex-row">
|
||||
<FileList
|
||||
orientation="vertical"
|
||||
recursive={true}
|
||||
style="width: {$rightPanelSize}px"
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
<!-- the open folder (the desktop app) under the files that are open -->
|
||||
{#if $workspace?.folder}
|
||||
{#if $treeFileView}
|
||||
<Resizer
|
||||
orientation="row"
|
||||
bind:after={() => explorerHeight, (height) => ($explorerPanelSize = height)}
|
||||
minAfter={60}
|
||||
maxAfter={Math.max(rightPanelHeight - 80, 60)}
|
||||
/>
|
||||
{/if}
|
||||
<div class="flex flex-col min-h-0 shrink-0" style="height: {explorerHeight}px">
|
||||
<Explorer />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<AlertDialog.Root open={$outdated}>
|
||||
<AlertDialog.Content escapeKeydownBehavior="ignore" interactOutsideBehavior="ignore">
|
||||
<AlertDialog.Header>
|
||||
<AlertDialog.Title>{i18n._('outdated.title')}</AlertDialog.Title>
|
||||
<AlertDialog.Description>{i18n._('outdated.description')}</AlertDialog.Description>
|
||||
</AlertDialog.Header>
|
||||
<AlertDialog.Footer>
|
||||
<AlertDialog.Action onclick={() => location.reload()}>
|
||||
{i18n._('outdated.reload')}
|
||||
</AlertDialog.Action>
|
||||
</AlertDialog.Footer>
|
||||
</AlertDialog.Content>
|
||||
</AlertDialog.Root>
|
||||
|
||||
<style lang="postcss">
|
||||
@reference "tailwindcss";
|
||||
|
||||
|
||||
Reference in new issue
Block a user