fix(web): boot rehydrate normalizes transfers; paused has its own visual

This commit is contained in:
Jannis Braun
2026-05-02 19:10:29 +02:00
parent 61be9d013f
commit 33cfc66ac4
4 changed files with 138 additions and 5 deletions
+17
View File
@@ -54,6 +54,23 @@ export function supportsDnDHandles(): boolean {
&& typeof (DataTransferItem.prototype as unknown as { getAsFileSystemHandle?: unknown }).getAsFileSystemHandle === 'function';
}
/**
* Silently query the current permission state on a stored handle.
* Never prompts; returns whatever the browser reports right now. Used by the
* boot-time rehydrate path so we can auto-resume only when permission is
* already 'granted' and avoid a "user gesture required" failure for 'prompt'.
*/
export async function queryHandlePermission(
handle: FileSystemHandle,
mode: 'read' | 'readwrite',
): Promise<PermissionState> {
const handleAny = handle as unknown as {
queryPermission?: (opts: { mode: string }) => Promise<PermissionState>;
};
if (typeof handleAny.queryPermission !== 'function') return 'denied';
return handleAny.queryPermission({ mode });
}
/**
* Re-prompt for permission on a stored handle. Returns 'granted', 'denied', or 'prompt'.
* Some non-standard FS Access surfaces don't expose `queryPermission`/`requestPermission` —