web: add local processing setting & api type

response is not handled at all yet, this is a raw draft
This commit is contained in:
wukko 2025-01-29 15:06:16 +06:00
parent c7c9cf2f0f
commit a43e7a629b
No known key found for this signature in database
GPG Key ID: 3E30B3F26C7B4AA2
10 changed files with 49 additions and 19 deletions

View File

@ -113,9 +113,9 @@
"advanced.data": "data management", "advanced.data": "data management",
"advanced.duck": "duck", "advanced.local-processing": "local processing",
"advanced.duck.title": "enable new on-device features", "advanced.local-processing.title": "mux and convert media on device",
"advanced.duck.description": "very wip, WILL cause critical issues or not work at all. this toggle will be gone by release.", "advanced.local-processing.description": "when downloading media, cobalt will use on-device processing to mux or convert it. exclusive local features such as remux or convert are not affected, they always run locally.",
"processing.community": "community instances", "processing.community": "community instances",
"processing.enable_custom.title": "use a custom processing server", "processing.enable_custom.title": "use a custom processing server",

View File

@ -35,10 +35,10 @@
<div id="sidebar-tabs" role="tablist"> <div id="sidebar-tabs" role="tablist">
<div id="sidebar-actions" class="sidebar-inner-container"> <div id="sidebar-actions" class="sidebar-inner-container">
<SidebarTab name="save" path="/" icon={IconDownload} /> <SidebarTab name="save" path="/" icon={IconDownload} />
{#if $settings.advanced.duck && !device.is.mobile && $settings.advanced.debug} <SidebarTab name="remux" path="/remux" icon={IconRepeat} beta />
{#if $settings.advanced.localProcessing && !device.is.mobile && $settings.advanced.debug}
<SidebarTab name="cutout" path="/cutout" icon={IconCut} beta /> <SidebarTab name="cutout" path="/cutout" icon={IconCut} beta />
{/if} {/if}
<SidebarTab name="remux" path="/remux" icon={IconRepeat} beta />
</div> </div>
<div id="sidebar-info" class="sidebar-inner-container"> <div id="sidebar-info" class="sidebar-inner-container">
<SidebarTab name="settings" path={settingsLink} icon={IconSettings} /> <SidebarTab name="settings" path={settingsLink} icon={IconSettings} />

View File

@ -66,6 +66,7 @@ const request = async (url: string) => {
tiktokH265: getSetting("save", "tiktokH265"), tiktokH265: getSetting("save", "tiktokH265"),
alwaysProxy: getSetting("privacy", "alwaysProxy"), alwaysProxy: getSetting("privacy", "alwaysProxy"),
localProcessing: getSetting("advanced", "localProcessing"),
} }
await getServerInfo(); await getServerInfo();

View File

@ -5,7 +5,7 @@ const defaultSettings: CobaltSettings = {
schemaVersion: 5, schemaVersion: 5,
advanced: { advanced: {
debug: false, debug: false,
duck: false, localProcessing: false,
}, },
appearance: { appearance: {
theme: "auto", theme: "auto",

View File

@ -3,6 +3,7 @@ enum CobaltResponseType {
Picker = 'picker', Picker = 'picker',
Redirect = 'redirect', Redirect = 'redirect',
Tunnel = 'tunnel', Tunnel = 'tunnel',
LocalProcessing = 'local-processing',
} }
export type CobaltErrorResponse = { export type CobaltErrorResponse = {
@ -40,6 +41,33 @@ type CobaltTunnelResponse = {
status: CobaltResponseType.Tunnel, status: CobaltResponseType.Tunnel,
} & CobaltPartialURLResponse; } & CobaltPartialURLResponse;
type CobaltLocalProcessingResponse = {
status: CobaltResponseType.LocalProcessing,
tunnel: string[],
// TODO: proper type for processing types
type: string,
service: string,
filename?: string,
metadata?: {
album?: string,
copyright?: string,
title?: string,
artist?: string,
track?: string,
date?: string
},
audio?: {
copy: boolean,
format: string,
bitrate: string,
},
isHLS?: boolean,
}
export type CobaltFileUrlType = "redirect" | "tunnel"; export type CobaltFileUrlType = "redirect" | "tunnel";
export type CobaltSession = { export type CobaltSession = {
@ -69,4 +97,5 @@ export type CobaltServerInfoResponse = CobaltServerInfo | CobaltErrorResponse;
export type CobaltAPIResponse = CobaltErrorResponse export type CobaltAPIResponse = CobaltErrorResponse
| CobaltPickerResponse | CobaltPickerResponse
| CobaltRedirectResponse | CobaltRedirectResponse
| CobaltTunnelResponse; | CobaltTunnelResponse
| CobaltLocalProcessingResponse;

View File

@ -3,6 +3,6 @@ import { type CobaltSettingsV4 } from "$lib/types/settings/v4";
export type CobaltSettingsV5 = Omit<CobaltSettingsV4, 'schemaVersion' | 'advanced'> & { export type CobaltSettingsV5 = Omit<CobaltSettingsV4, 'schemaVersion' | 'advanced'> & {
schemaVersion: 5, schemaVersion: 5,
advanced: CobaltSettingsV4['advanced'] & { advanced: CobaltSettingsV4['advanced'] & {
duck: boolean; localProcessing: boolean;
}; };
}; };

View File

@ -91,7 +91,7 @@
<UpdateNotification /> <UpdateNotification />
{/if} {/if}
<div id="content"> <div id="content">
{#if $settings.advanced.duck} {#if $settings.advanced.localProcessing}
<ProcessingQueue /> <ProcessingQueue />
{/if} {/if}
{#if ($turnstileEnabled && $page.url.pathname === "/") || $turnstileCreated} {#if ($turnstileEnabled && $page.url.pathname === "/") || $turnstileCreated}

View File

@ -73,7 +73,7 @@
}; };
onMount(() => { onMount(() => {
if (!($settings.advanced.duck && $settings.advanced.debug)) { if (!($settings.advanced.localProcessing && $settings.advanced.debug)) {
goto("/", { replaceState: true }); goto("/", { replaceState: true });
} }
}); });

View File

@ -15,15 +15,6 @@
/> />
</SettingsCategory> </SettingsCategory>
<SettingsCategory sectionId="local-processing" title={$t("settings.advanced.duck")} beta>
<SettingsToggle
settingContext="advanced"
settingId="duck"
title={$t("settings.advanced.duck.title")}
description={$t("settings.advanced.duck.description")}
/>
</SettingsCategory>
<SettingsCategory sectionId="data" title={$t("settings.advanced.data")}> <SettingsCategory sectionId="data" title={$t("settings.advanced.data")}>
<ManageSettings /> <ManageSettings />
</SettingsCategory> </SettingsCategory>

View File

@ -56,6 +56,15 @@
/> />
</SettingsCategory> </SettingsCategory>
<SettingsCategory sectionId="local-processing" title={$t("settings.advanced.local-processing")} beta>
<SettingsToggle
settingContext="advanced"
settingId="localProcessing"
title={$t("settings.advanced.local-processing.title")}
description={$t("settings.advanced.local-processing.description")}
/>
</SettingsCategory>
<style> <style>
.category-inside-group { .category-inside-group {
display: flex; display: flex;