SilverBullet pivot to become an offline-first PWA (#403)

This commit is contained in:
Zef Hemel
2023-05-23 20:53:53 +02:00
committed by GitHub
parent b256269897
commit 5f484bed57
389 changed files with 4484 additions and 291129 deletions
+5 -41
View File
@@ -1,45 +1,9 @@
import type { SyncStatusItem } from "../../common/spaces/sync.ts";
import { syscall } from "./syscall.ts";
import { syscall } from "$sb/silverbullet-syscall/syscall.ts";
export type SyncEndpoint = {
url: string;
user?: string;
password?: string;
excludePrefixes?: string[];
};
// Perform a sync with the server, based on the given status (to be persisted)
// returns a new sync status to persist
export function syncAll(
endpoint: SyncEndpoint,
snapshot: Record<string, SyncStatusItem>,
): Promise<
{
snapshot: Record<string, SyncStatusItem>;
operations: number;
error?: string;
}
> {
return syscall("sync.syncAll", endpoint, snapshot);
export function isSyncing(): Promise<boolean> {
return syscall("sync.isSyncing");
}
// Perform a sync with the server, based on the given status (to be persisted)
// returns a new sync status to persist
export function syncFile(
endpoint: SyncEndpoint,
snapshot: Record<string, SyncStatusItem>,
name: string,
): Promise<
{
snapshot: Record<string, SyncStatusItem>;
operations: number;
error?: string;
}
> {
return syscall("sync.syncFile", endpoint, snapshot, name);
}
// Checks the sync endpoint for connectivity and authentication, throws and Error on failure
export function check(endpoint: SyncEndpoint): Promise<void> {
return syscall("sync.check", endpoint);
export function hasInitialSyncCompleted(): Promise<boolean> {
return syscall("sync.hasInitialSyncCompleted");
}