bump svelte-loadable-store

This commit is contained in:
Nikita Galaiko 2023-07-11 15:12:08 +02:00
parent a1b034c5d3
commit 82939782eb
19 changed files with 58 additions and 65 deletions

View File

@ -84,7 +84,7 @@
"svelte-check": "^3.0.1",
"svelte-floating-ui": "^1.5.2",
"svelte-french-toast": "^1.0.3",
"svelte-loadable-store": "^1.2.3",
"svelte-loadable-store": "^2.0.0",
"svelte-outclick": "^3.5.0",
"svelte-resize-observer": "^2.0.0",
"tailwindcss": "^3.1.5",

View File

@ -200,8 +200,8 @@ devDependencies:
specifier: ^1.0.3
version: 1.0.3(svelte@3.55.1)
svelte-loadable-store:
specifier: ^1.2.3
version: 1.2.3(svelte@3.55.1)
specifier: ^2.0.0
version: 2.0.0(svelte@3.55.1)
svelte-outclick:
specifier: ^3.5.0
version: 3.5.0(svelte@3.55.1)
@ -213,10 +213,10 @@ devDependencies:
version: 3.2.4(postcss@8.4.21)
tauri-plugin-log-api:
specifier: github:tauri-apps/tauri-plugin-log
version: github.com/tauri-apps/tauri-plugin-log/21921031d74f871180381317a338559f588ad8e9
version: github.com/tauri-apps/tauri-plugin-log/fbbb126e6d7fba7a7e6772d33f99c0fb689f32b6
tauri-plugin-websocket-api:
specifier: github:tauri-apps/tauri-plugin-websocket
version: github.com/tauri-apps/tauri-plugin-websocket/7832cb121d2ecaf6b52c9bdee77df18fddaac5d9
version: github.com/tauri-apps/tauri-plugin-websocket/39b7ba2c0c27a9b0093b00120830ed23774f5403
tinykeys:
specifier: ^1.4.0
version: 1.4.0
@ -4717,8 +4717,8 @@ packages:
svelte: 3.55.1
dev: true
/svelte-loadable-store@1.2.3(svelte@3.55.1):
resolution: {integrity: sha512-efoCRCGLxzU+RE1D09cpnKKBO2CVXAzjUY0/RatOtPXSNPbb0/HeGcV/baH5davabwiDm7iWf2rqI9ogIRQ1Pw==}
/svelte-loadable-store@2.0.0(svelte@3.55.1):
resolution: {integrity: sha512-2mnbj99fnbQg4WwXW3WZWUqAbcaXkHacFFulb7r+VdSic9PkkKq/117V94lVeCrC9BxMR7KaOdESE7+JZTsWxg==}
peerDependencies:
svelte: ^3.0.0
dependencies:
@ -5459,16 +5459,16 @@ packages:
engines: {node: '>=12.20'}
dev: true
github.com/tauri-apps/tauri-plugin-log/21921031d74f871180381317a338559f588ad8e9:
resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-log/tar.gz/21921031d74f871180381317a338559f588ad8e9}
github.com/tauri-apps/tauri-plugin-log/fbbb126e6d7fba7a7e6772d33f99c0fb689f32b6:
resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-log/tar.gz/fbbb126e6d7fba7a7e6772d33f99c0fb689f32b6}
name: tauri-plugin-log-api
version: 0.0.0
dependencies:
'@tauri-apps/api': 1.4.0
dev: true
github.com/tauri-apps/tauri-plugin-websocket/7832cb121d2ecaf6b52c9bdee77df18fddaac5d9:
resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-websocket/tar.gz/7832cb121d2ecaf6b52c9bdee77df18fddaac5d9}
github.com/tauri-apps/tauri-plugin-websocket/39b7ba2c0c27a9b0093b00120830ed23774f5403:
resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-websocket/tar.gz/39b7ba2c0c27a9b0093b00120830ed23774f5403}
name: tauri-plugin-websocket-api
version: 0.0.0
dependencies:

View File

@ -1,4 +1,4 @@
import { writable, type Loadable, derived, Value } from 'svelte-loadable-store';
import { writable, type Loadable, derived, Loaded } from 'svelte-loadable-store';
import { bookmarks, type Bookmark } from '$lib/api';
import { get as getValue, type Readable } from '@square/svelte-store';
@ -12,7 +12,7 @@ export function list(params: { projectId: string }) {
const oldValue = getValue(store);
if (oldValue.isLoading) {
bookmarks.list(params).then(set);
} else if (Value.isError(oldValue.value)) {
} else if (Loaded.isError(oldValue)) {
bookmarks.list(params).then(set);
} else {
set(oldValue.value.filter((b) => b.timestampMs !== bookmark.timestampMs).concat(bookmark));

View File

@ -1,4 +1,4 @@
import { writable, type Loadable, Value } from 'svelte-loadable-store';
import { writable, type Loadable, Loaded } from 'svelte-loadable-store';
import { deltas, type Delta } from '$lib/api';
import { get, type Readable } from '@square/svelte-store';
@ -13,7 +13,7 @@ export default (params: { projectId: string; sessionId: string }) => {
const oldValue = get(store);
if (oldValue.isLoading) {
deltas.list(params).then(set);
} else if (Value.isError(oldValue.value)) {
} else if (Loaded.isError(oldValue)) {
deltas.list(params).then(set);
} else {
set({

View File

@ -1,4 +1,4 @@
import { writable, type Loadable, Value } from 'svelte-loadable-store';
import { writable, type Loadable, Loaded } from 'svelte-loadable-store';
import { files } from '$lib/api';
import { get, type Readable } from '@square/svelte-store';
@ -13,7 +13,7 @@ export default (params: { projectId: string; sessionId: string }) => {
const oldValue = get(store);
if (oldValue.isLoading) {
files.list(params).then(set);
} else if (Value.isError(oldValue.value)) {
} else if (Loaded.isError(oldValue)) {
files.list(params).then(set);
} else {
set({

View File

@ -1,4 +1,4 @@
import { derived, writable, type Loadable, Value } from 'svelte-loadable-store';
import { derived, writable, type Loadable, Loaded } from 'svelte-loadable-store';
import { sessions, type Session } from '$lib/api';
import { get, type Readable } from '@square/svelte-store';
@ -13,7 +13,7 @@ export default (params: { projectId: string }) => {
const oldValue = get(store);
if (oldValue.isLoading) {
sessions.list(params).then(set);
} else if (Value.isError(oldValue.value)) {
} else if (Loaded.isError(oldValue)) {
sessions.list(params).then(set);
} else {
set(

View File

@ -1,4 +1,4 @@
import { writable, type Loadable, Value } from 'svelte-loadable-store';
import { writable, type Loadable, Loaded } from 'svelte-loadable-store';
import type { Readable } from '@square/svelte-store';
import { git } from '$lib/api/ipc';
import { stores } from '$lib';
@ -19,10 +19,11 @@ export class BranchStoresCache {
if (cachedStore) {
return cachedStore;
}
const writableStore = writable(ipc.listVirtualBranches({ projectId }), (set) => {
stores.sessions({ projectId }).subscribe((sessions) => {
if (sessions.isLoading) return;
if (Value.isError(sessions.value)) return;
if (Loaded.isError(sessions)) return;
const lastSession = sessions.value.at(-1);
if (!lastSession) return;
return stores.deltas({ projectId, sessionId: lastSession.id }).subscribe(() => {

View File

@ -2,7 +2,7 @@
import { format, startOfDay } from 'date-fns';
import type { Delta } from '$lib/api';
import { generateBuckets } from './histogram';
import { derived, Value } from 'svelte-loadable-store';
import { derived, Loaded } from 'svelte-loadable-store';
import FileActivity from './FileActivity.svelte';
import { page } from '$app/stores';
import { Link } from '$lib/components';
@ -44,7 +44,7 @@
<h2 class="text-2xl font-bold text-zinc-400">Loading file changes...</h2>
</div>
</li>
{:else if Value.isError($deltasByDate.value) || Value.isError($buckets.value)}
{:else if Loaded.isError($deltasByDate) || Loaded.isError($buckets)}
<li class="flex flex-1 space-y-4 rounded-lg border border-dashed border-zinc-400">
<div class="flex flex-1 flex-col items-center justify-center gap-4">
<IconSparkle class="h-16 w-16 text-zinc-400 " />

View File

@ -2,7 +2,7 @@
import { page } from '$app/stores';
import { stores, api } from '$lib';
import { format } from 'date-fns';
import { derived, Value } from 'svelte-loadable-store';
import { derived, Loaded } from 'svelte-loadable-store';
const sessions = stores.sessions({ projectId: $page.params.projectId });
@ -32,7 +32,7 @@
</script>
<div id="player-page" class="flex h-full w-full flex-col">
{#if !$dates.isLoading && Value.isValue($dates.value)}
{#if !$dates.isLoading && Loaded.isValue($dates)}
{#if $dates.value.length === 0}
<div class="text-center">
<h2 class="text-2xl">I haven't seen any changes yet</h2>

View File

@ -1,7 +1,7 @@
<script lang="ts">
import type { LayoutData } from './$types';
import { page } from '$app/stores';
import { derived, Value } from 'svelte-loadable-store';
import { derived, Loaded } from 'svelte-loadable-store';
import { format } from 'date-fns';
import { onMount } from 'svelte';
import { api, events, hotkeys, stores } from '$lib';
@ -85,7 +85,7 @@
<IconLoading class="mb-4 h-12 w-12 animate-spin ease-linear" />
<h2 class="text-center text-2xl font-medium text-gray-500">Loading...</h2>
</div>
{:else if Value.isError($richSessions.value) || Value.isError($currentSession.value)}
{:else if Loaded.isError($richSessions) || Loaded.isError($currentSession)}
<div class="flex h-full flex-col items-center justify-center">
<h2 class="text-center text-2xl font-medium text-gray-500">Error</h2>
</div>
@ -102,10 +102,10 @@
<header class="flex items-center gap-3 bg-card-active px-3 py-2">
{#if $currentSession.isLoading || $richSessions.isLoading}
<span>Loading...</span>
{:else if Loaded.isError($currentSession) || Loaded.isError($richSessions)}
<span>Error</span>
{:else if !$currentSession.value}
<span>No session found</span>
{:else if Value.isError($currentSession.value) || Value.isError($richSessions.value)}
<span>Error</span>
{:else}
<SessionNavigations currentSession={$currentSession.value} sessions={$richSessions.value} />
{/if}

View File

@ -5,9 +5,9 @@
import { derived } from '@square/svelte-store';
import { stores } from '$lib';
import { IconBookmarkFilled } from '$lib/icons';
import { Value } from 'svelte-loadable-store';
import { line } from '$lib/diff';
import { Stats } from '$lib/components';
import { Loaded } from 'svelte-loadable-store';
export let isCurrent: boolean;
export let session: Session;
@ -53,7 +53,7 @@
$: bookmarks = derived(stores.bookmarks.list({ projectId: session.projectId }), (bookmarks) => {
if (bookmarks.isLoading) return [];
if (Value.isError(bookmarks.value)) return [];
if (Loaded.isError(bookmarks)) return [];
const timestamps = Object.values(deltas ?? {}).flatMap((deltas) =>
deltas.map((d) => d.timestampMs)
);

View File

@ -8,7 +8,7 @@
import { unsubscribe } from '$lib/utils';
import type { Readable } from '@square/svelte-store';
import { onMount } from 'svelte';
import { Value, type Loadable } from 'svelte-loadable-store';
import { Loaded, type Loadable } from 'svelte-loadable-store';
import { derived } from 'svelte-loadable-store';
import { format } from 'date-fns';
@ -57,19 +57,11 @@
onMount(() =>
unsubscribe(
hotkeys.on('Shift+ArrowRight', () => {
if (
!$nextSessionId.isLoading &&
Value.isValue($nextSessionId.value) &&
$nextSessionId.value
)
if (!$nextSessionId.isLoading && Loaded.isValue($nextSessionId) && $nextSessionId.value)
goto(getSessionURI($nextSessionId.value));
}),
hotkeys.on('Shift+ArrowLeft', () => {
if (
!$prevSessionId.isLoading &&
Value.isValue($prevSessionId.value) &&
$prevSessionId.value
)
if (!$prevSessionId.isLoading && Loaded.isValue($prevSessionId) && $prevSessionId.value)
goto(getSessionURI($prevSessionId.value));
})
)
@ -83,7 +75,7 @@
</span>
<div class="flex items-center gap-1">
{#if !$prevSessionId.isLoading && !$nextSessionId.isLoading && Value.isValue($prevSessionId.value) && Value.isValue($nextSessionId.value)}
{#if !$prevSessionId.isLoading && !$nextSessionId.isLoading && Loaded.isValue($prevSessionId) && Loaded.isValue($nextSessionId)}
<a
href={$prevSessionId.value && getSessionURI($prevSessionId.value)}
class="rounded border border-zinc-500 bg-zinc-600 p-0.5"

View File

@ -1,7 +1,7 @@
<script lang="ts">
import type { Delta, Session } from '$lib/api';
import type { Readable } from '@square/svelte-store';
import { Value, type Loadable } from 'svelte-loadable-store';
import { Loaded, type Loadable } from 'svelte-loadable-store';
import { derived } from 'svelte-loadable-store';
import SessionCard from './SessionCard.svelte';
@ -26,7 +26,7 @@
...session,
visible:
!$visibleDeltas.isLoading &&
!Value.isError($visibleDeltas.value) &&
!Loaded.isError($visibleDeltas) &&
Object.keys($visibleDeltas.value[i]).length > 0
}));
</script>
@ -48,7 +48,7 @@
>
{#each visibleSessions as session, i}
{@const isCurrent = session.id === currentSession?.id}
{#if session.visible && !$visibleDeltas.isLoading && !Value.isError($visibleDeltas.value) && !$visibleFiles.isLoading && !Value.isError($visibleFiles.value)}
{#if session.visible && !$visibleDeltas.isLoading && !Loaded.isError($visibleDeltas) && !$visibleFiles.isLoading && !Loaded.isError($visibleFiles)}
<SessionCard
{isCurrent}
{session}

View File

@ -3,7 +3,7 @@
import type { PageData } from './$types';
import { page } from '$app/stores';
import { get, writable } from '@square/svelte-store';
import { derived, Value } from 'svelte-loadable-store';
import { derived, Loaded } from 'svelte-loadable-store';
import { format } from 'date-fns';
import { stores } from '$lib';
import Playback from './Playback.svelte';
@ -55,7 +55,7 @@
richSessions?.subscribe((sessions) => {
if (sessions.isLoading) return;
if (Value.isError(sessions.value)) return;
if (Loaded.isError(sessions)) return;
if (sessions.value.length === 0) return;
if (!sessions.value.some((s) => s.id === $currentSessionId)) {
$currentSessionId = sessions.value[0].id;
@ -74,7 +74,7 @@
$: {
// this hook updates player value if current page url has changed
if (!$richSessions.isLoading && Value.isValue($richSessions.value)) {
if (!$richSessions.isLoading && Loaded.isValue($richSessions)) {
const currentSessionIndex = $richSessions.value.findIndex(
(s) => s.id === $page.params.sessionId
);
@ -83,7 +83,7 @@
.filter((_, index) => index < currentSessionIndex)
.reduce((acc, s) => {
const deltas = get(s.deltas);
if (!deltas.isLoading && Value.isValue(deltas.value)) {
if (!deltas.isLoading && Loaded.isValue(deltas)) {
return acc + deltas.value.length;
} else {
return acc;
@ -100,7 +100,7 @@
/>
<h2 class="text-center text-2xl font-medium text-gray-500">Loading...</h2>
</div>
{:else if Value.isError($richSessions.value)}
{:else if Loaded.isError($richSessions)}
<div class="flex h-full flex-col items-center justify-center">
<h2 class="text-center text-2xl font-medium text-gray-500">Something went wrong</h2>
</div>

View File

@ -3,7 +3,7 @@
import type { Frame } from './frame';
import { DeltasViewer } from '$lib/components';
import type { Readable } from '@square/svelte-store';
import { Value, type Loadable } from 'svelte-loadable-store';
import { Loaded, type Loadable } from 'svelte-loadable-store';
export let context: number;
export let fullContext: boolean;
@ -17,8 +17,8 @@
if (
!$deltas.isLoading &&
!$files.isLoading &&
Value.isValue($deltas.value) &&
Value.isValue($files.value)
Loaded.isValue($deltas) &&
Loaded.isValue($files)
) {
let i = value;
for (const j in $deltas.value) {

View File

@ -3,8 +3,8 @@
import { collapse } from '$lib/paths';
import { IconBookmark, IconBookmarkFilled } from '$lib/icons';
import { format } from 'date-fns';
import { Value } from 'svelte-loadable-store';
import { page } from '$app/stores';
import { Loaded } from 'svelte-loadable-store';
export let timestampMs: number;
export let filename: string;
@ -13,7 +13,7 @@
const toggleBookmark = () => {
if ($bookmark.isLoading) return;
if (Value.isError($bookmark.value)) return;
if (Loaded.isError($bookmark)) return;
api.bookmarks.upsert(
!$bookmark.value
? {
@ -30,7 +30,7 @@
};
</script>
{#if !$bookmark.isLoading && !Value.isError($bookmark.value)}
{#if !$bookmark.isLoading && !Loaded.isError($bookmark)}
<div
class="flex max-w-[357px] flex-col gap-2 rounded-[18px] py-2 px-4 shadow"
style="border: 0.5px solid rgba(63, 63, 70, 0.5);

View File

@ -6,7 +6,7 @@
import { onMount } from 'svelte';
import { hotkeys } from '$lib';
import type { Readable } from '@square/svelte-store';
import { type Loadable, derived, Value } from 'svelte-loadable-store';
import { type Loadable, derived, Loaded } from 'svelte-loadable-store';
export let value: number;
export let context: number;
@ -39,7 +39,7 @@
const gotoNextDelta = () => {
if ($maxDeltaIndex.isLoading) return;
if (Value.isError($maxDeltaIndex.value)) return;
if (Loaded.isError($maxDeltaIndex)) return;
if (value < $maxDeltaIndex.value) {
value += 1;
} else {

View File

@ -1,6 +1,6 @@
<script lang="ts">
import type { Bookmark, Delta } from '$lib/api';
import { derived, Value, type Loadable } from 'svelte-loadable-store';
import { derived, Loaded, type Loadable } from 'svelte-loadable-store';
import type { Readable } from '@square/svelte-store';
import { ModuleChapters, ModuleMarkers, type Marker } from './slider';
import { JSR, ModuleSlider } from 'mm-jsr';
@ -89,7 +89,7 @@
};
</script>
{#if !$totalDeltas.isLoading && Value.isValue($totalDeltas.value) && !$chapters.isLoading && Value.isValue($chapters.value) && !$markers.isLoading && Value.isValue($markers.value)}
{#if !$totalDeltas.isLoading && Loaded.isValue($totalDeltas) && !$chapters.isLoading && Loaded.isValue($chapters) && !$markers.isLoading && Loaded.isValue($markers)}
<div
use:jsrSlider={{
min: 0,

View File

@ -2,9 +2,9 @@
import Board from './Board.svelte';
import Tray from './Tray.svelte';
import type { PageData } from './$types';
import { Value } from 'svelte-loadable-store';
import { Button } from '$lib/components';
import { BranchController } from '$lib/vbranches';
import { Loaded } from 'svelte-loadable-store';
export let data: PageData;
let {
@ -25,15 +25,15 @@
);
$: remoteBranches =
!$remoteBranchStore.isLoading && !Value.isError($remoteBranchStore.value)
!$remoteBranchStore.isLoading && !Loaded.isError($remoteBranchStore)
? $remoteBranchStore.value
: [];
$: target =
!$targetBranchStore.isLoading && !Value.isError($targetBranchStore.value)
!$targetBranchStore.isLoading && !Loaded.isError($targetBranchStore)
? $targetBranchStore.value
: undefined;
$: branches =
!$vbranchStore.isLoading && !Value.isError($vbranchStore.value) ? $vbranchStore.value : [];
!$vbranchStore.isLoading && !Loaded.isError($vbranchStore) ? $vbranchStore.value : [];
let targetChoice: string | undefined;
function onSetTargetClick() {