Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/AreaObservations.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The zone where dragging can be performed is defined by the _parent element_ of t
import IconExpand from '~icons/ri/arrow-right-s-line';
import IconTrash from '~icons/ri/delete-bin-line';
import { IsMobile } from '$lib/mobile.svelte.js';
import { uiState } from '$lib/state.svelte.js';
import { uiState } from '$lib/uistate.svelte.js';

import ButtonIcon from './ButtonIcon.svelte';
import ButtonInk from './ButtonInk.svelte';
Expand Down
40 changes: 40 additions & 0 deletions src/lib/BottomDrawer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
maxHeight?: number;
title?: string;
position?: BottomSheetSettings['position'];
trigger?: Snippet;
/** The trigger will be the bottom bar. The value of this prop is the text shown. */
'trigger-from-bottombar'?: string;
}
</script>

Expand All @@ -23,19 +26,42 @@

import { BottomSheet } from 'svelte-bottom-sheet';

import IconShowPanel from '~icons/ri/arrow-up-s-line';
import BottombarContent from '$routes/(app)/BottombarContent.svelte';

import { mutationobserver } from './mutations.js';
import { onswipe } from './touch/swipes.js';

let {
open = $bindable(false),
title = '',
children,
maxHeight = 0.7,
position = 'bottom',
trigger,
'trigger-from-bottombar': triggerFromBottombar,
}: Props = $props();

let disableGestures = $state(false);
</script>

{#if triggerFromBottombar}
<BottombarContent>
<button
class="open-drawer"
{@attach onswipe('up', () => {
open = true;
})}
onclick={() => {
open = true;
}}
>
{triggerFromBottombar}
<IconShowPanel />
</button>
</BottombarContent>
{/if}

<div
data-bottomsheet-wrapper
use:mutationobserver={{
Expand All @@ -57,6 +83,11 @@
}}
bind:isSheetOpen={open}
>
{#if trigger}
<BottomSheet.Trigger>
{@render trigger()}
</BottomSheet.Trigger>
{/if}
<BottomSheet.Overlay>
<BottomSheet.Sheet>
<BottomSheet.Handle>
Expand Down Expand Up @@ -128,4 +159,13 @@
background-color: var(--gray);
margin: 0.5em auto;
}

button.open-drawer {
display: flex;
align-items: center;
gap: 0.5em;
justify-content: space-between;
width: 100%;
font-size: 1rem;
}
</style>
2 changes: 1 addition & 1 deletion src/lib/CardImage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { toTopLeftCoords } from './BoundingBoxes.svelte';
import CardMedia from './CardMedia.svelte';
import { isDebugMode } from './settings.svelte.js';
import { uiState } from './state.svelte.js';
import { uiState } from './uistate.svelte.js';

/**
* @import * as DB from '$lib/database.js';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/CardImageFile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { toTopLeftCoords } from './BoundingBoxes.svelte.js';
import CardMedia from './CardMedia.svelte';
import { isDebugMode } from './settings.svelte.js';
import { uiState } from './state.svelte.js';
import { uiState } from './uistate.svelte.js';
import { nonnull } from './utils.js';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/CardMedia.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import Logo from './Logo.svelte';
import { IsMobile } from './mobile.svelte.js';
import OverflowableText from './OverflowableText.svelte';
import { uiState } from './state.svelte.js';
import { uiState } from './uistate.svelte.js';
import { tooltip } from './tooltips.js';
import { onlongpress } from './touch/longpress.js';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/CardObservation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import CardMedia from './CardMedia.svelte';
import { tables } from './idb.svelte.js';
import { isDebugMode } from './settings.svelte.js';
import { uiState } from './state.svelte.js';
import { uiState } from './uistate.svelte.js';
import { nonnull } from './utils.js';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/KeyboardShortcuts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { entries } from './utils.js';

/**
* @import { Keybind, Keymap } from '$lib/state.svelte.js'
* @import { Keybind, Keymap } from '$lib/uistate.svelte.js'
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/MetadataCascadesTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { tables } from './idb.svelte.js';
import OverflowableText from './OverflowableText.svelte';
import { uiState } from './state.svelte.js';
import { uiState } from './uistate.svelte.js';
import { compareBy, readableOn } from './utils.js';

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/MetadataComboboxDesktop.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { metadataOptionsOf, serializeMetadataValue } from './metadata/index.js';
import MetadataCascadesTable from './MetadataCascadesTable.svelte';
import { namespaceOfMetadataId } from './schemas/metadata.js';
import { uiState } from './state.svelte';
import { uiState } from './uistate.svelte.js';
import { cancellable, readableOn } from './utils.js';

let {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/MetadataComboboxMobile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import { scrollfader } from './scrollfader.js';
import { makeSearcher } from './search.js';
import { isDebugMode } from './settings.svelte.js';
import { uiState } from './state.svelte.js';
import { uiState } from './uistate.svelte.js';
import TabbedView from './TabbedView.svelte';
import {
compareBy,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/MetadataInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import { sendNotification } from './notifications.js';
import OverflowableText from './OverflowableText.svelte';
import { availableUnitsFor, displayUnit, NumericUnit, unitKind } from './schemas/units.js';
import { uiState } from './state.svelte.js';
import { uiState } from './uistate.svelte.js';
import { resolveObjectWithBytes } from './storage/utils.js';
import Switch from './Switch.svelte';
import { toasts } from './toasts.svelte.js';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/classification.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { databaseHandle, tables } from './idb.svelte.js';
import { inferenceModelId } from './inference.js';
import { storeMetadataErrors } from './metadata/storage.js';
import { metadataDefinitionComparator } from './protocols.js';
import { uiState } from './state.svelte.js';
import { uiState } from './uistate.svelte.js';
import { safeJSONStringify } from './utils.js';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/images.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ulid } from 'ulid';

import { uiState } from '$lib/state.svelte';
import { uiState } from '$lib/uistate.svelte.js';

import { toTopLeftCoords } from './BoundingBoxes.svelte.js';
import { errorMessage, humanFormatName } from './i18n.js';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/import.svelte.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
resizeToMaxSize,
storeImageBytes,
} from '$lib/images.js';
import { uiState } from '$lib/state.svelte.js';
import { uiState } from '$lib/uistate.svelte.js';
import { toasts } from '$lib/toasts.svelte.js';

import { setExifFields } from './exif.js';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/inference.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export function modelUrl(model) {
* @param {AbortSignal} [taskSettings.abortSignal]
* @param {ArrayBuffer[]} buffers
* @param {import('onnxruntime-web').InferenceSession} session
* @param {typeof import('./state.svelte.js').uiState} [uiState]
* @param {typeof import('./uistate.svelte.js').uiState} [uiState]
* @param {boolean} sequence
* @param {boolean} webgpu
* @returns {Promise<[BB[][], number[][], number, ort.Tensor[]]>}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/keyboard.svelte.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { onDestroy, onMount } from 'svelte';

import { uiState } from './state.svelte.js';
import { uiState } from './uistate.svelte.js';
import { entries, keys } from './utils.js';

const GROUPS = {
Expand All @@ -19,7 +19,7 @@ const GROUPS = {
*
* This function will _not_ override any keybind that already has an existing key shortcut defined.
* @param {keyof typeof GROUPS} group used to group keybinds together in help dialogs, applied to all keybinds defined here, unless they override it themselves
* @param {import("./state.svelte").Keymap<keyof typeof GROUPS>} shortcuts
* @param {import("./uistate.svelte.js").Keymap<keyof typeof GROUPS>} shortcuts
* WARNING: If you rename this function, update `heuristic` in `wuchale.config.js`
*/
export function defineKeyboardShortcuts(group, shortcuts) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/observations.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
mergeMetadataFromImagesAndObservations,
serializeMetadataFullValue,
} from './metadata/index.js';
import { uiState } from './state.svelte.js';
import { uiState } from './uistate.svelte.js';
import { compareBy, mapValues, nonnull, transformObject } from './utils.js';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/queue.svelte.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { inferBoundingBoxes, processImageFile } from './import.svelte.js';
import { sendNotification } from './notifications.js';
import { importResultsZip } from './results.svelte.js';
import { isSidecar } from './sidecars.js';
import { uiState } from './state.svelte.js';
import { uiState } from './uistate.svelte.js';
import { isZip, range } from './utils.js';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/results.svelte.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { serializeMetadataValue } from './metadata/index.js';
import { Analysis } from './schemas/exports.js';
import { ANALYSIS_JSON_ZIP_FILEPATH } from './schemas/protocols.js';
import { switchSession } from './sessions.js';
import { uiState } from './state.svelte.js';
import { uiState } from './uistate.svelte.js';
import { toasts } from './toasts.svelte.js';
import { entries, mapValues, pick, safeJSONParse, uint8ArrayToArrayBuffer } from './utils.js';

Expand Down
1 change: 1 addition & 0 deletions src/lib/schemas/protocols.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export const ExportedProtocol = Protocol.omit(
'importedMetadata'
)
.in.and({
'$schema?': 'string',
imports: ProtocolImport.array().default(() => []),
'metadataGroups?': type.Record(
ID,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/seo.svelte.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { uiState } from './state.svelte';
import { uiState } from './uistate.svelte.js';

/**
*
Expand Down
2 changes: 1 addition & 1 deletion src/lib/sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as idb from '$lib/idb.svelte.js';
import { imageIdToFileId } from './images.js';
import { clearMetadataOptionsCache } from './metadata/storage.js';
import { withQueue } from './queue.svelte.js';
import { uiState } from './state.svelte.js';
import { uiState } from './uistate.svelte.js';
import { undo } from './undo.svelte.js';

/**
Expand Down
22 changes: 11 additions & 11 deletions src/lib/state.svelte.js → src/lib/uistate.svelte.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { isMetadataInProtocol } from './schemas/protocols.js';
import { mapValues, omit, pick, transformObject } from './utils.js';

/**
* @import * as DB from './database';
* @import * as DB from './database.js';
* @import { NamespacedMetadataID } from './schemas/common.js';
* @import { TypedMetadataValue } from './metadata/index.js';
*/
Expand Down Expand Up @@ -170,12 +170,12 @@ export class UIState {
this._currentSessionId = id;
}

/** @type {import('./database').Session | undefined} */
/** @type {import('./database.js').Session | undefined} */
currentSession = $derived(tables.Session.state.find((s) => s.id === this.currentSessionId));

currentProtocolId = $derived(this.currentSession?.protocol);

/** @type {import('./database').Protocol | undefined} */
/** @type {import('./database.js').Protocol | undefined} */
currentProtocol = $derived(tables.Protocol.state.find((p) => p.id === this.currentProtocolId));

classificationMetadata = $derived(
Expand All @@ -196,16 +196,16 @@ export class UIState {
cropMetadataId = $derived(this.cropMetadata?.id ?? 'backbone__crop');

/**
* @param {import('./database').Image} image
* @returns {import('./metadata').TypedMetadataValue<'boundingbox'>|undefined}
* @param {import('./database.js').Image} image
* @returns {import('./metadata/index.js').TypedMetadataValue<'boundingbox'>|undefined}
*/
cropMetadataValueOf(image) {
return getMetadataValue(image, 'boundingbox', this.cropMetadataId);
}

/**
* @param {import('./database').Image} image
* @returns {import('./metadata').TypedMetadataValue<'enum'>|undefined}
* @param {import('./database.js').Image} image
* @returns {import('./metadata/index.js').TypedMetadataValue<'enum'>|undefined}
*/

classificationMetadataValueOf(image) {
Expand Down Expand Up @@ -275,7 +275,7 @@ export class UIState {

/**
* Classification metadata with an enabled neural model selection.
* @type {import('./database').Metadata[]}
* @type {import('./database.js').Metadata[]}
*/
enabledClassificationMetadata = $derived.by(() => {
return this.allClassificationMetadata.filter(
Expand All @@ -285,7 +285,7 @@ export class UIState {

/**
* All metadata with neural enum inference (not just the first one)
* @type {import('./database').Metadata[]}
* @type {import('./database.js').Metadata[]}
*/
allClassificationMetadata = $derived.by(() => {
const protocol = this.currentProtocol;
Expand All @@ -299,7 +299,7 @@ export class UIState {

/**
* Maps metadata IDs to their neural inference models
* @type {import('./database').Metadata['id'] extends string ? Record<import('./database').Metadata['id'], typeof import('$lib/schemas/neural.js').NeuralEnumInference.infer[]> : never}
* @type {import('./database.js').Metadata['id'] extends string ? Record<import('./database.js').Metadata['id'], typeof import('$lib/schemas/neural.js').NeuralEnumInference.infer[]> : never}
*/
allClassificationModels = $derived.by(() => {
/** @type {Record<string, any>} */
Expand All @@ -315,7 +315,7 @@ export class UIState {

/**
* Maps metadata IDs to their selected model indices
* @type {import('./database').Metadata['id'] extends string ? Record<import('./database').Metadata['id'], number> : never}
* @type {import('./database.js').Metadata['id'] extends string ? Record<import('./database.js').Metadata['id'], number> : never}
*/
selectedClassificationModels = $derived.by(() => {
/** @type {Record<string, number>} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'fake-indexeddb/auto';
import { beforeEach, describe, expect, it, test } from 'vitest';

import { _tablesState, nukeDatabase } from './idb.svelte.js';
import { UIState } from './state.svelte.js';
import { UIState } from './uistate.svelte.js';
import { keys } from './utils.js';

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(app)/(sidepanel)/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { deleteObservation, mergeToObservation, newObservation } from '$lib/observations';
import { cancelTask, importMore } from '$lib/queue.svelte.js';
import { seo } from '$lib/seo.svelte';
import { uiState } from '$lib/state.svelte';
import { uiState } from '$lib/uistate.svelte.js';
import { toasts } from '$lib/toasts.svelte';

import TopbarOpenSession from '../TopbarOpenSession.svelte';
Expand Down
Loading
Loading