feat(player): queue

This commit is contained in:
2024-11-27 01:54:32 +01:00
parent c93d47efc1
commit 60613e6502
14 changed files with 1492 additions and 1564 deletions

View File

@@ -6,16 +6,20 @@ import 'library.proto';
package player;
service Player {
rpc PlayTrack(PlayTrackRequest) returns (PlayTrackResponse);
rpc PlayTrack(TrackRequest) returns (PlayTrackResponse);
rpc ResumeTrack(google.protobuf.Empty) returns (PauseState);
rpc PauseTrack(google.protobuf.Empty) returns (PauseState);
rpc TogglePause(google.protobuf.Empty) returns (PauseState);
rpc GetStatus(google.protobuf.Empty) returns (stream PlayerStatus);
rpc SeekPosition(SeekPositionRequest) returns (SeekPositionResponse);
rpc SetVolume(SetVolumeRequest) returns (SetVolumeResponse);
rpc PlayTrackNext(TrackRequest) returns (Queue);
rpc AddTrackToQueue(TrackRequest) returns (Queue);
rpc SkipTrack(google.protobuf.Empty) returns (PlayerStatus);
rpc SkipToQueueIndex(SkipToQueueIndexRequest) returns (PlayerStatus);
}
message PlayTrackRequest {
message TrackRequest {
string hash = 1;
}
@@ -29,6 +33,11 @@ message PlayerStatus {
bool is_paused = 2;
float volume = 3;
uint64 progress = 4;
repeated library.Track queue = 5;
}
message Queue {
repeated library.Track tracks = 1;
}
message PauseState {
@@ -50,3 +59,7 @@ message SetVolumeRequest {
message SetVolumeResponse {
float volume = 1;
}
message SkipToQueueIndexRequest {
uint32 index = 1;
}

View File

@@ -55,14 +55,22 @@
console.log(`SKIP TO QUEUE INDEX ${index}`);
}
const submitTogglePause: SubmitFunction = async () => {
const submitPlayerAction: SubmitFunction = async () => {
return async ({ update, result }) => {
await update({
invalidateAll: false
});
if (result.type === 'success' && result.data && 'isPaused' in result.data) {
player.isPaused = result.data.isPaused;
if (result.type !== 'success' || !result.data) {
return;
}
if ('isPaused' in result.data) {
if (!('volume' in result.data)) {
player.isPaused = result.data.isPaused;
} else {
player.applyStatus(result.data);
}
}
};
};
@@ -93,9 +101,9 @@
<form
class="col-span-1 flex justify-center gap-1"
method="POST"
use:enhance={submitTogglePause}
use:enhance={submitPlayerAction}
>
<Button variant="outline" size="icon">
<Button variant="outline" size="icon" disabled>
<SkipBack />
</Button>
<Button type="submit" formaction="/player?/toggle-pause" variant="outline" size="icon">
@@ -105,7 +113,7 @@
<Pause />
{/if}
</Button>
<Button variant="outline" size="icon">
<Button type="submit" variant="outline" formaction="/player?/skip" size="icon">
<SkipForward />
</Button>
</form>
@@ -116,7 +124,7 @@
{#snippet child({ props })}
<Button {...props} variant="ghost" size="sm">
<List class="mr-2 size-4" />
<span>15</span>
<span>{player.queue.length}</span>
</Button>
{/snippet}
</Popover.Trigger>
@@ -125,34 +133,35 @@
<Separator class="my-1" />
<div class="flex h-full flex-col gap-1 overflow-y-auto pr-3">
{#each [] as _track, i}
<form
class="flex h-full flex-col gap-1 overflow-y-auto pr-3"
method="POST"
use:enhance={submitPlayerAction}
>
{#each player.queue as track, i}
<button
type="submit"
class="flex flex-row items-center gap-2 rounded-lg px-3 py-2 transition-all hover:bg-secondary"
onclick={() => skipToQueueIndex(i)}
formaction="/player?/skip-to-queue-index&index={i}"
>
<div class="min-w-8 overflow-hidden rounded-md">
<img
src="https://i.scdn.co/image/ab67616d0000b2732c0ead8ce0dd1c6e2fca817f"
class="aspect-square size-8"
alt="Cover"
/>
<img src={getCoverUrl(track.hash)} class="aspect-square size-8" alt="Cover" />
</div>
<div class="flex flex-col overflow-hidden">
<p
class="w-full self-start overflow-hidden text-ellipsis text-nowrap text-left text-sm text-foreground/80"
>
Track name
{track.name}
</p>
<p
class="w-full self-start overflow-hidden text-left text-xs text-muted-foreground"
>
Track artist
{track.artistName}
</p>
</div>
</button>
{/each}
</div>
</form>
</Popover.Content>
</Popover.Root>

View File

@@ -2,11 +2,10 @@
import { enhance } from '$app/forms';
import { getCoverUrl } from '$lib/covers';
import { getPlayerState } from '$lib/player.svelte';
// import { AudioLines } from 'lucide-svelte';
import { AudioLines } from 'lucide-svelte';
import { AudioLines, Music2, ListMusic, ListEnd } from 'lucide-svelte';
import type { SubmitFunction } from '../../../routes/tracks/[hash]/$types';
import type { Track } from '$lib/proto/library';
import * as ContextMenu from '$lib/components/ui/context-menu';
interface Props {
track: Track;
@@ -14,21 +13,44 @@
let { track }: Props = $props();
let isOpen = $state(false);
const player = getPlayerState();
const submitPlayTrack: SubmitFunction = async () => {
return async ({ update, result }) => {
isOpen = false;
await update({
invalidateAll: false
});
if (result.type === 'success' && result.data) {
if (result.type === 'success' && result.data && 'track' in result.data) {
player.queue = [];
player.currentlyPlaying = result.data.track ?? null;
player.progress = result.data.position;
player.isPaused = false;
}
};
};
const submitEnqueue: SubmitFunction = async () => {
return async ({ update, result }) => {
isOpen = false;
await update({
invalidateAll: false
});
if (result.type === 'success' && result.data && 'tracks' in result.data) {
player.queue = result.data.tracks;
}
};
};
function contextMenuItemClicked(e: MouseEvent) {
e.stopPropagation();
}
</script>
<form
@@ -37,24 +59,81 @@
action="/tracks/{track.hash}?/play"
use:enhance={submitPlayTrack}
>
<div class="relative">
<button type="submit" class="relative overflow-hidden rounded-lg">
<img
class="aspect-square w-auto transition-all duration-150 hover:scale-105 hover:saturate-150"
src={getCoverUrl(track.hash)}
alt={track.name}
/>
</button>
<ContextMenu.Root bind:open={isOpen}>
<ContextMenu.Trigger>
<div class="relative">
<button type="submit" class="relative overflow-hidden rounded-lg">
<img
class="aspect-square w-auto transition-all duration-150 hover:scale-105 hover:saturate-150"
src={getCoverUrl(track.hash)}
alt={track.name}
/>
</button>
<div
class="absolute bottom-6 left-2 size-4 animate-pulse"
class:hidden={player.currentlyPlaying?.hash !== track.hash}
>
<AudioLines class="text-primary" />
</div>
</div>
<div class="relative space-y-1 text-sm">
<h3 class="font-medium leading-none">{track.name}</h3>
<p class="text-xs text-muted-foreground">{track.artistName}</p>
</div>
<div
class="absolute bottom-6 left-2 size-4 animate-pulse"
class:hidden={player.currentlyPlaying?.hash !== track.hash}
>
<AudioLines class="text-primary" />
</div>
</div>
<div class="relative space-y-1 text-sm">
<h3 class="font-medium leading-none">{track.name}</h3>
<p class="text-xs text-muted-foreground">{track.artistName}</p>
</div>
</ContextMenu.Trigger>
<ContextMenu.Content>
<ContextMenu.Item class="!p-0">
<form
class="flex w-full"
method="POST"
action="/tracks/{track.hash}?/play"
use:enhance={submitPlayTrack}
>
<button
type="submit"
class="flex w-full items-center px-2 py-1.5 focus:outline-0"
onclick={contextMenuItemClicked}
>
<Music2 class="mr-1 size-4" />
Play
</button>
</form>
</ContextMenu.Item>
<ContextMenu.Item class="!p-0">
<form
class="flex w-full"
method="POST"
action="/tracks/{track.hash}?/play-next"
use:enhance={submitEnqueue}
>
<button
type="submit"
class="flex w-full items-center px-2 py-1.5 focus:outline-0"
onclick={contextMenuItemClicked}
>
<ListMusic class="mr-1 size-4" />
Play Next
</button>
</form>
</ContextMenu.Item>
<ContextMenu.Item class="!p-0">
<form
class="flex w-full"
method="POST"
action="/tracks/{track.hash}?/add-to-queue"
use:enhance={submitEnqueue}
>
<button
type="submit"
class="flex w-full items-center px-2 py-1.5 focus:outline-0"
onclick={contextMenuItemClicked}
>
<ListEnd class="mr-1 size-4" />
Add to Queue
</button>
</form>
</ContextMenu.Item>
</ContextMenu.Content>
</ContextMenu.Root>
</form>

View File

@@ -10,6 +10,7 @@ class PlayerState {
progress = $state<bigint>(0n);
isPaused = $state(false);
adjustingVolume = $state(false);
queue = $state<Track[]>([]);
#abortContoller: AbortController | null = null;
constructor() {
@@ -34,6 +35,7 @@ class PlayerState {
this.progress = status.progress;
this.currentlyPlaying = status.currentlyPlaying ?? null;
this.isPaused = status.isPaused;
this.queue = status.queue;
}
abort() {

View File

@@ -6,7 +6,18 @@ export function serializable<F, T extends object = object>(data: T): F {
if (typeof value === 'object') {
/// @ts-ignore
obj[key] = serializable(value);
if ('length' in value) {
/// @ts-ignore
obj[key] =
value.length > 0
? value.map((v) => {
return typeof v === 'object' ? serializable(v) : v;
})
: [];
} else {
/// @ts-ignore
obj[key] = serializable(value);
}
} else {
/// @ts-ignore
obj[key] = value;

View File

@@ -32,14 +32,14 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
import type { BinaryWriteOptions } from '@protobuf-ts/runtime';
import type { IBinaryWriter } from '@protobuf-ts/runtime';
import { UnknownFieldHandler } from '@protobuf-ts/runtime';
import type { BinaryReadOptions } from '@protobuf-ts/runtime';
import type { IBinaryReader } from '@protobuf-ts/runtime';
import type { PartialMessage } from '@protobuf-ts/runtime';
import { reflectionMergePartial } from '@protobuf-ts/runtime';
import { MessageType } from '@protobuf-ts/runtime';
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
import type { IBinaryWriter } from "@protobuf-ts/runtime";
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
import type { IBinaryReader } from "@protobuf-ts/runtime";
import type { PartialMessage } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
/**
* A generic empty message that you can re-use to avoid defining duplicated
* empty messages in your APIs. A typical example is to use it as the request
@@ -52,34 +52,28 @@ import { MessageType } from '@protobuf-ts/runtime';
*
* @generated from protobuf message google.protobuf.Empty
*/
export interface Empty {}
export interface Empty {
}
// @generated message type with reflection information, may provide speed optimized methods
class Empty$Type extends MessageType<Empty> {
constructor() {
super('google.protobuf.Empty', []);
}
create(value?: PartialMessage<Empty>): Empty {
const message = globalThis.Object.create(this.messagePrototype!);
if (value !== undefined) reflectionMergePartial<Empty>(this, message, value);
return message;
}
internalBinaryRead(
reader: IBinaryReader,
length: number,
options: BinaryReadOptions,
target?: Empty
): Empty {
return target ?? this.create();
}
internalBinaryWrite(
message: Empty,
writer: IBinaryWriter,
options: BinaryWriteOptions
): IBinaryWriter {
let u = options.writeUnknownFields;
if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
constructor() {
super("google.protobuf.Empty", []);
}
create(value?: PartialMessage<Empty>): Empty {
const message = globalThis.Object.create((this.messagePrototype!));
if (value !== undefined)
reflectionMergePartial<Empty>(this, message, value);
return message;
}
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Empty): Empty {
return target ?? this.create();
}
internalBinaryWrite(message: Empty, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message google.protobuf.Empty

View File

@@ -1,37 +1,37 @@
// @generated by protobuf-ts 2.9.4
// @generated from protobuf file "library.proto" (package "library", syntax proto3)
// tslint:disable
import type { RpcTransport } from '@protobuf-ts/runtime-rpc';
import type { ServiceInfo } from '@protobuf-ts/runtime-rpc';
import { Library } from './library';
import { stackIntercept } from '@protobuf-ts/runtime-rpc';
import type { TrackList } from './library';
import type { Empty } from './google/protobuf/empty';
import type { UnaryCall } from '@protobuf-ts/runtime-rpc';
import type { RpcOptions } from '@protobuf-ts/runtime-rpc';
import type { RpcTransport } from "@protobuf-ts/runtime-rpc";
import type { ServiceInfo } from "@protobuf-ts/runtime-rpc";
import { Library } from "./library";
import { stackIntercept } from "@protobuf-ts/runtime-rpc";
import type { TrackList } from "./library";
import type { Empty } from "./google/protobuf/empty";
import type { UnaryCall } from "@protobuf-ts/runtime-rpc";
import type { RpcOptions } from "@protobuf-ts/runtime-rpc";
/**
* @generated from protobuf service library.Library
*/
export interface ILibraryClient {
/**
* @generated from protobuf rpc: ListTracks(google.protobuf.Empty) returns (library.TrackList);
*/
listTracks(input: Empty, options?: RpcOptions): UnaryCall<Empty, TrackList>;
/**
* @generated from protobuf rpc: ListTracks(google.protobuf.Empty) returns (library.TrackList);
*/
listTracks(input: Empty, options?: RpcOptions): UnaryCall<Empty, TrackList>;
}
/**
* @generated from protobuf service library.Library
*/
export class LibraryClient implements ILibraryClient, ServiceInfo {
typeName = Library.typeName;
methods = Library.methods;
options = Library.options;
constructor(private readonly _transport: RpcTransport) {}
/**
* @generated from protobuf rpc: ListTracks(google.protobuf.Empty) returns (library.TrackList);
*/
listTracks(input: Empty, options?: RpcOptions): UnaryCall<Empty, TrackList> {
const method = this.methods[0],
opt = this._transport.mergeOptions(options);
return stackIntercept<Empty, TrackList>('unary', this._transport, method, opt, input);
}
typeName = Library.typeName;
methods = Library.methods;
options = Library.options;
constructor(private readonly _transport: RpcTransport) {
}
/**
* @generated from protobuf rpc: ListTracks(google.protobuf.Empty) returns (library.TrackList);
*/
listTracks(input: Empty, options?: RpcOptions): UnaryCall<Empty, TrackList> {
const method = this.methods[0], opt = this._transport.mergeOptions(options);
return stackIntercept<Empty, TrackList>("unary", this._transport, method, opt, input);
}
}

View File

@@ -1,113 +1,93 @@
// @generated by protobuf-ts 2.9.4
// @generated from protobuf file "library.proto" (package "library", syntax proto3)
// tslint:disable
import { Empty } from './google/protobuf/empty';
import { ServiceType } from '@protobuf-ts/runtime-rpc';
import type { BinaryWriteOptions } from '@protobuf-ts/runtime';
import type { IBinaryWriter } from '@protobuf-ts/runtime';
import { WireType } from '@protobuf-ts/runtime';
import type { BinaryReadOptions } from '@protobuf-ts/runtime';
import type { IBinaryReader } from '@protobuf-ts/runtime';
import { UnknownFieldHandler } from '@protobuf-ts/runtime';
import type { PartialMessage } from '@protobuf-ts/runtime';
import { reflectionMergePartial } from '@protobuf-ts/runtime';
import { MessageType } from '@protobuf-ts/runtime';
import { Empty } from "./google/protobuf/empty";
import { ServiceType } from "@protobuf-ts/runtime-rpc";
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
import type { IBinaryWriter } from "@protobuf-ts/runtime";
import { WireType } from "@protobuf-ts/runtime";
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
import type { IBinaryReader } from "@protobuf-ts/runtime";
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
import type { PartialMessage } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
/**
* @generated from protobuf message library.TrackList
*/
export interface TrackList {
/**
* @generated from protobuf field: repeated library.Track tracks = 1;
*/
tracks: Track[];
/**
* @generated from protobuf field: repeated library.Track tracks = 1;
*/
tracks: Track[];
}
/**
* @generated from protobuf message library.Track
*/
export interface Track {
/**
* @generated from protobuf field: string hash = 1;
*/
hash: string;
/**
* @generated from protobuf field: string name = 2;
*/
name: string;
/**
* @generated from protobuf field: string artist_name = 3;
*/
artistName: string;
/**
* @generated from protobuf field: uint64 artist_id = 4;
*/
artistId: bigint;
/**
* @generated from protobuf field: uint64 duration = 5;
*/
duration: bigint;
/**
* @generated from protobuf field: string hash = 1;
*/
hash: string;
/**
* @generated from protobuf field: string name = 2;
*/
name: string;
/**
* @generated from protobuf field: string artist_name = 3;
*/
artistName: string;
/**
* @generated from protobuf field: uint64 artist_id = 4;
*/
artistId: bigint;
/**
* @generated from protobuf field: uint64 duration = 5;
*/
duration: bigint;
}
// @generated message type with reflection information, may provide speed optimized methods
class TrackList$Type extends MessageType<TrackList> {
constructor() {
super('library.TrackList', [
{ no: 1, name: 'tracks', kind: 'message', repeat: 1 /*RepeatType.PACKED*/, T: () => Track }
]);
}
create(value?: PartialMessage<TrackList>): TrackList {
const message = globalThis.Object.create(this.messagePrototype!);
message.tracks = [];
if (value !== undefined) reflectionMergePartial<TrackList>(this, message, value);
return message;
}
internalBinaryRead(
reader: IBinaryReader,
length: number,
options: BinaryReadOptions,
target?: TrackList
): TrackList {
let message = target ?? this.create(),
end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* repeated library.Track tracks */ 1:
message.tracks.push(Track.internalBinaryRead(reader, reader.uint32(), options));
break;
default:
let u = options.readUnknownField;
if (u === 'throw')
throw new globalThis.Error(
`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(
this.typeName,
message,
fieldNo,
wireType,
d
);
}
}
return message;
}
internalBinaryWrite(
message: TrackList,
writer: IBinaryWriter,
options: BinaryWriteOptions
): IBinaryWriter {
/* repeated library.Track tracks = 1; */
for (let i = 0; i < message.tracks.length; i++)
Track.internalBinaryWrite(
message.tracks[i],
writer.tag(1, WireType.LengthDelimited).fork(),
options
).join();
let u = options.writeUnknownFields;
if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
constructor() {
super("library.TrackList", [
{ no: 1, name: "tracks", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => Track }
]);
}
create(value?: PartialMessage<TrackList>): TrackList {
const message = globalThis.Object.create((this.messagePrototype!));
message.tracks = [];
if (value !== undefined)
reflectionMergePartial<TrackList>(this, message, value);
return message;
}
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: TrackList): TrackList {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* repeated library.Track tracks */ 1:
message.tracks.push(Track.internalBinaryRead(reader, reader.uint32(), options));
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message: TrackList, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* repeated library.Track tracks = 1; */
for (let i = 0; i < message.tracks.length; i++)
Track.internalBinaryWrite(message.tracks[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join();
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message library.TrackList
@@ -115,102 +95,78 @@ class TrackList$Type extends MessageType<TrackList> {
export const TrackList = new TrackList$Type();
// @generated message type with reflection information, may provide speed optimized methods
class Track$Type extends MessageType<Track> {
constructor() {
super('library.Track', [
{ no: 1, name: 'hash', kind: 'scalar', T: 9 /*ScalarType.STRING*/ },
{ no: 2, name: 'name', kind: 'scalar', T: 9 /*ScalarType.STRING*/ },
{ no: 3, name: 'artist_name', kind: 'scalar', T: 9 /*ScalarType.STRING*/ },
{
no: 4,
name: 'artist_id',
kind: 'scalar',
T: 4 /*ScalarType.UINT64*/,
L: 0 /*LongType.BIGINT*/
},
{
no: 5,
name: 'duration',
kind: 'scalar',
T: 4 /*ScalarType.UINT64*/,
L: 0 /*LongType.BIGINT*/
}
]);
}
create(value?: PartialMessage<Track>): Track {
const message = globalThis.Object.create(this.messagePrototype!);
message.hash = '';
message.name = '';
message.artistName = '';
message.artistId = 0n;
message.duration = 0n;
if (value !== undefined) reflectionMergePartial<Track>(this, message, value);
return message;
}
internalBinaryRead(
reader: IBinaryReader,
length: number,
options: BinaryReadOptions,
target?: Track
): Track {
let message = target ?? this.create(),
end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* string hash */ 1:
message.hash = reader.string();
break;
case /* string name */ 2:
message.name = reader.string();
break;
case /* string artist_name */ 3:
message.artistName = reader.string();
break;
case /* uint64 artist_id */ 4:
message.artistId = reader.uint64().toBigInt();
break;
case /* uint64 duration */ 5:
message.duration = reader.uint64().toBigInt();
break;
default:
let u = options.readUnknownField;
if (u === 'throw')
throw new globalThis.Error(
`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(
this.typeName,
message,
fieldNo,
wireType,
d
);
}
}
return message;
}
internalBinaryWrite(
message: Track,
writer: IBinaryWriter,
options: BinaryWriteOptions
): IBinaryWriter {
/* string hash = 1; */
if (message.hash !== '') writer.tag(1, WireType.LengthDelimited).string(message.hash);
/* string name = 2; */
if (message.name !== '') writer.tag(2, WireType.LengthDelimited).string(message.name);
/* string artist_name = 3; */
if (message.artistName !== '')
writer.tag(3, WireType.LengthDelimited).string(message.artistName);
/* uint64 artist_id = 4; */
if (message.artistId !== 0n) writer.tag(4, WireType.Varint).uint64(message.artistId);
/* uint64 duration = 5; */
if (message.duration !== 0n) writer.tag(5, WireType.Varint).uint64(message.duration);
let u = options.writeUnknownFields;
if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
constructor() {
super("library.Track", [
{ no: 1, name: "hash", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 2, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 3, name: "artist_name", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 4, name: "artist_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 5, name: "duration", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }
]);
}
create(value?: PartialMessage<Track>): Track {
const message = globalThis.Object.create((this.messagePrototype!));
message.hash = "";
message.name = "";
message.artistName = "";
message.artistId = 0n;
message.duration = 0n;
if (value !== undefined)
reflectionMergePartial<Track>(this, message, value);
return message;
}
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Track): Track {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* string hash */ 1:
message.hash = reader.string();
break;
case /* string name */ 2:
message.name = reader.string();
break;
case /* string artist_name */ 3:
message.artistName = reader.string();
break;
case /* uint64 artist_id */ 4:
message.artistId = reader.uint64().toBigInt();
break;
case /* uint64 duration */ 5:
message.duration = reader.uint64().toBigInt();
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message: Track, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* string hash = 1; */
if (message.hash !== "")
writer.tag(1, WireType.LengthDelimited).string(message.hash);
/* string name = 2; */
if (message.name !== "")
writer.tag(2, WireType.LengthDelimited).string(message.name);
/* string artist_name = 3; */
if (message.artistName !== "")
writer.tag(3, WireType.LengthDelimited).string(message.artistName);
/* uint64 artist_id = 4; */
if (message.artistId !== 0n)
writer.tag(4, WireType.Varint).uint64(message.artistId);
/* uint64 duration = 5; */
if (message.duration !== 0n)
writer.tag(5, WireType.Varint).uint64(message.duration);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message library.Track
@@ -219,6 +175,6 @@ export const Track = new Track$Type();
/**
* @generated ServiceType for protobuf service library.Library
*/
export const Library = new ServiceType('library.Library', [
{ name: 'ListTracks', options: {}, I: Empty, O: TrackList }
export const Library = new ServiceType("library.Library", [
{ name: "ListTracks", options: {}, I: Empty, O: TrackList }
]);

View File

@@ -1,159 +1,157 @@
// @generated by protobuf-ts 2.9.4
// @generated from protobuf file "player.proto" (package "player", syntax proto3)
// tslint:disable
import type { RpcTransport } from '@protobuf-ts/runtime-rpc';
import type { ServiceInfo } from '@protobuf-ts/runtime-rpc';
import { Player } from './player';
import type { SetVolumeResponse } from './player';
import type { SetVolumeRequest } from './player';
import type { SeekPositionResponse } from './player';
import type { SeekPositionRequest } from './player';
import type { PlayerStatus } from './player';
import type { ServerStreamingCall } from '@protobuf-ts/runtime-rpc';
import type { PauseState } from './player';
import type { Empty } from './google/protobuf/empty';
import { stackIntercept } from '@protobuf-ts/runtime-rpc';
import type { PlayTrackResponse } from './player';
import type { PlayTrackRequest } from './player';
import type { UnaryCall } from '@protobuf-ts/runtime-rpc';
import type { RpcOptions } from '@protobuf-ts/runtime-rpc';
import type { RpcTransport } from "@protobuf-ts/runtime-rpc";
import type { ServiceInfo } from "@protobuf-ts/runtime-rpc";
import { Player } from "./player";
import type { SkipToQueueIndexRequest } from "./player";
import type { Queue } from "./player";
import type { SetVolumeResponse } from "./player";
import type { SetVolumeRequest } from "./player";
import type { SeekPositionResponse } from "./player";
import type { SeekPositionRequest } from "./player";
import type { PlayerStatus } from "./player";
import type { ServerStreamingCall } from "@protobuf-ts/runtime-rpc";
import type { PauseState } from "./player";
import type { Empty } from "./google/protobuf/empty";
import { stackIntercept } from "@protobuf-ts/runtime-rpc";
import type { PlayTrackResponse } from "./player";
import type { TrackRequest } from "./player";
import type { UnaryCall } from "@protobuf-ts/runtime-rpc";
import type { RpcOptions } from "@protobuf-ts/runtime-rpc";
/**
* @generated from protobuf service player.Player
*/
export interface IPlayerClient {
/**
* @generated from protobuf rpc: PlayTrack(player.PlayTrackRequest) returns (player.PlayTrackResponse);
*/
playTrack(
input: PlayTrackRequest,
options?: RpcOptions
): UnaryCall<PlayTrackRequest, PlayTrackResponse>;
/**
* @generated from protobuf rpc: ResumeTrack(google.protobuf.Empty) returns (player.PauseState);
*/
resumeTrack(input: Empty, options?: RpcOptions): UnaryCall<Empty, PauseState>;
/**
* @generated from protobuf rpc: PauseTrack(google.protobuf.Empty) returns (player.PauseState);
*/
pauseTrack(input: Empty, options?: RpcOptions): UnaryCall<Empty, PauseState>;
/**
* @generated from protobuf rpc: TogglePause(google.protobuf.Empty) returns (player.PauseState);
*/
togglePause(input: Empty, options?: RpcOptions): UnaryCall<Empty, PauseState>;
/**
* @generated from protobuf rpc: GetStatus(google.protobuf.Empty) returns (stream player.PlayerStatus);
*/
getStatus(input: Empty, options?: RpcOptions): ServerStreamingCall<Empty, PlayerStatus>;
/**
* @generated from protobuf rpc: SeekPosition(player.SeekPositionRequest) returns (player.SeekPositionResponse);
*/
seekPosition(
input: SeekPositionRequest,
options?: RpcOptions
): UnaryCall<SeekPositionRequest, SeekPositionResponse>;
/**
* @generated from protobuf rpc: SetVolume(player.SetVolumeRequest) returns (player.SetVolumeResponse);
*/
setVolume(
input: SetVolumeRequest,
options?: RpcOptions
): UnaryCall<SetVolumeRequest, SetVolumeResponse>;
/**
* @generated from protobuf rpc: PlayTrack(player.TrackRequest) returns (player.PlayTrackResponse);
*/
playTrack(input: TrackRequest, options?: RpcOptions): UnaryCall<TrackRequest, PlayTrackResponse>;
/**
* @generated from protobuf rpc: ResumeTrack(google.protobuf.Empty) returns (player.PauseState);
*/
resumeTrack(input: Empty, options?: RpcOptions): UnaryCall<Empty, PauseState>;
/**
* @generated from protobuf rpc: PauseTrack(google.protobuf.Empty) returns (player.PauseState);
*/
pauseTrack(input: Empty, options?: RpcOptions): UnaryCall<Empty, PauseState>;
/**
* @generated from protobuf rpc: TogglePause(google.protobuf.Empty) returns (player.PauseState);
*/
togglePause(input: Empty, options?: RpcOptions): UnaryCall<Empty, PauseState>;
/**
* @generated from protobuf rpc: GetStatus(google.protobuf.Empty) returns (stream player.PlayerStatus);
*/
getStatus(input: Empty, options?: RpcOptions): ServerStreamingCall<Empty, PlayerStatus>;
/**
* @generated from protobuf rpc: SeekPosition(player.SeekPositionRequest) returns (player.SeekPositionResponse);
*/
seekPosition(input: SeekPositionRequest, options?: RpcOptions): UnaryCall<SeekPositionRequest, SeekPositionResponse>;
/**
* @generated from protobuf rpc: SetVolume(player.SetVolumeRequest) returns (player.SetVolumeResponse);
*/
setVolume(input: SetVolumeRequest, options?: RpcOptions): UnaryCall<SetVolumeRequest, SetVolumeResponse>;
/**
* @generated from protobuf rpc: PlayTrackNext(player.TrackRequest) returns (player.Queue);
*/
playTrackNext(input: TrackRequest, options?: RpcOptions): UnaryCall<TrackRequest, Queue>;
/**
* @generated from protobuf rpc: AddTrackToQueue(player.TrackRequest) returns (player.Queue);
*/
addTrackToQueue(input: TrackRequest, options?: RpcOptions): UnaryCall<TrackRequest, Queue>;
/**
* @generated from protobuf rpc: SkipTrack(google.protobuf.Empty) returns (player.PlayerStatus);
*/
skipTrack(input: Empty, options?: RpcOptions): UnaryCall<Empty, PlayerStatus>;
/**
* @generated from protobuf rpc: SkipToQueueIndex(player.SkipToQueueIndexRequest) returns (player.PlayerStatus);
*/
skipToQueueIndex(input: SkipToQueueIndexRequest, options?: RpcOptions): UnaryCall<SkipToQueueIndexRequest, PlayerStatus>;
}
/**
* @generated from protobuf service player.Player
*/
export class PlayerClient implements IPlayerClient, ServiceInfo {
typeName = Player.typeName;
methods = Player.methods;
options = Player.options;
constructor(private readonly _transport: RpcTransport) {}
/**
* @generated from protobuf rpc: PlayTrack(player.PlayTrackRequest) returns (player.PlayTrackResponse);
*/
playTrack(
input: PlayTrackRequest,
options?: RpcOptions
): UnaryCall<PlayTrackRequest, PlayTrackResponse> {
const method = this.methods[0],
opt = this._transport.mergeOptions(options);
return stackIntercept<PlayTrackRequest, PlayTrackResponse>(
'unary',
this._transport,
method,
opt,
input
);
}
/**
* @generated from protobuf rpc: ResumeTrack(google.protobuf.Empty) returns (player.PauseState);
*/
resumeTrack(input: Empty, options?: RpcOptions): UnaryCall<Empty, PauseState> {
const method = this.methods[1],
opt = this._transport.mergeOptions(options);
return stackIntercept<Empty, PauseState>('unary', this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: PauseTrack(google.protobuf.Empty) returns (player.PauseState);
*/
pauseTrack(input: Empty, options?: RpcOptions): UnaryCall<Empty, PauseState> {
const method = this.methods[2],
opt = this._transport.mergeOptions(options);
return stackIntercept<Empty, PauseState>('unary', this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: TogglePause(google.protobuf.Empty) returns (player.PauseState);
*/
togglePause(input: Empty, options?: RpcOptions): UnaryCall<Empty, PauseState> {
const method = this.methods[3],
opt = this._transport.mergeOptions(options);
return stackIntercept<Empty, PauseState>('unary', this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: GetStatus(google.protobuf.Empty) returns (stream player.PlayerStatus);
*/
getStatus(input: Empty, options?: RpcOptions): ServerStreamingCall<Empty, PlayerStatus> {
const method = this.methods[4],
opt = this._transport.mergeOptions(options);
return stackIntercept<Empty, PlayerStatus>(
'serverStreaming',
this._transport,
method,
opt,
input
);
}
/**
* @generated from protobuf rpc: SeekPosition(player.SeekPositionRequest) returns (player.SeekPositionResponse);
*/
seekPosition(
input: SeekPositionRequest,
options?: RpcOptions
): UnaryCall<SeekPositionRequest, SeekPositionResponse> {
const method = this.methods[5],
opt = this._transport.mergeOptions(options);
return stackIntercept<SeekPositionRequest, SeekPositionResponse>(
'unary',
this._transport,
method,
opt,
input
);
}
/**
* @generated from protobuf rpc: SetVolume(player.SetVolumeRequest) returns (player.SetVolumeResponse);
*/
setVolume(
input: SetVolumeRequest,
options?: RpcOptions
): UnaryCall<SetVolumeRequest, SetVolumeResponse> {
const method = this.methods[6],
opt = this._transport.mergeOptions(options);
return stackIntercept<SetVolumeRequest, SetVolumeResponse>(
'unary',
this._transport,
method,
opt,
input
);
}
typeName = Player.typeName;
methods = Player.methods;
options = Player.options;
constructor(private readonly _transport: RpcTransport) {
}
/**
* @generated from protobuf rpc: PlayTrack(player.TrackRequest) returns (player.PlayTrackResponse);
*/
playTrack(input: TrackRequest, options?: RpcOptions): UnaryCall<TrackRequest, PlayTrackResponse> {
const method = this.methods[0], opt = this._transport.mergeOptions(options);
return stackIntercept<TrackRequest, PlayTrackResponse>("unary", this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: ResumeTrack(google.protobuf.Empty) returns (player.PauseState);
*/
resumeTrack(input: Empty, options?: RpcOptions): UnaryCall<Empty, PauseState> {
const method = this.methods[1], opt = this._transport.mergeOptions(options);
return stackIntercept<Empty, PauseState>("unary", this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: PauseTrack(google.protobuf.Empty) returns (player.PauseState);
*/
pauseTrack(input: Empty, options?: RpcOptions): UnaryCall<Empty, PauseState> {
const method = this.methods[2], opt = this._transport.mergeOptions(options);
return stackIntercept<Empty, PauseState>("unary", this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: TogglePause(google.protobuf.Empty) returns (player.PauseState);
*/
togglePause(input: Empty, options?: RpcOptions): UnaryCall<Empty, PauseState> {
const method = this.methods[3], opt = this._transport.mergeOptions(options);
return stackIntercept<Empty, PauseState>("unary", this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: GetStatus(google.protobuf.Empty) returns (stream player.PlayerStatus);
*/
getStatus(input: Empty, options?: RpcOptions): ServerStreamingCall<Empty, PlayerStatus> {
const method = this.methods[4], opt = this._transport.mergeOptions(options);
return stackIntercept<Empty, PlayerStatus>("serverStreaming", this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: SeekPosition(player.SeekPositionRequest) returns (player.SeekPositionResponse);
*/
seekPosition(input: SeekPositionRequest, options?: RpcOptions): UnaryCall<SeekPositionRequest, SeekPositionResponse> {
const method = this.methods[5], opt = this._transport.mergeOptions(options);
return stackIntercept<SeekPositionRequest, SeekPositionResponse>("unary", this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: SetVolume(player.SetVolumeRequest) returns (player.SetVolumeResponse);
*/
setVolume(input: SetVolumeRequest, options?: RpcOptions): UnaryCall<SetVolumeRequest, SetVolumeResponse> {
const method = this.methods[6], opt = this._transport.mergeOptions(options);
return stackIntercept<SetVolumeRequest, SetVolumeResponse>("unary", this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: PlayTrackNext(player.TrackRequest) returns (player.Queue);
*/
playTrackNext(input: TrackRequest, options?: RpcOptions): UnaryCall<TrackRequest, Queue> {
const method = this.methods[7], opt = this._transport.mergeOptions(options);
return stackIntercept<TrackRequest, Queue>("unary", this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: AddTrackToQueue(player.TrackRequest) returns (player.Queue);
*/
addTrackToQueue(input: TrackRequest, options?: RpcOptions): UnaryCall<TrackRequest, Queue> {
const method = this.methods[8], opt = this._transport.mergeOptions(options);
return stackIntercept<TrackRequest, Queue>("unary", this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: SkipTrack(google.protobuf.Empty) returns (player.PlayerStatus);
*/
skipTrack(input: Empty, options?: RpcOptions): UnaryCall<Empty, PlayerStatus> {
const method = this.methods[9], opt = this._transport.mergeOptions(options);
return stackIntercept<Empty, PlayerStatus>("unary", this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: SkipToQueueIndex(player.SkipToQueueIndexRequest) returns (player.PlayerStatus);
*/
skipToQueueIndex(input: SkipToQueueIndexRequest, options?: RpcOptions): UnaryCall<SkipToQueueIndexRequest, PlayerStatus> {
const method = this.methods[10], opt = this._transport.mergeOptions(options);
return stackIntercept<SkipToQueueIndexRequest, PlayerStatus>("unary", this._transport, method, opt, input);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,109 +1,76 @@
// @generated by protobuf-ts 2.9.4
// @generated from protobuf file "settings.proto" (package "settings", syntax proto3)
// tslint:disable
import type { RpcTransport } from '@protobuf-ts/runtime-rpc';
import type { ServiceInfo } from '@protobuf-ts/runtime-rpc';
import { Settings } from './settings';
import type { RefreshPathResponse } from './settings';
import type { RefreshPathRequest } from './settings';
import type { DeletePathResponse } from './settings';
import type { DeletePathRequest } from './settings';
import type { AddPathResponse } from './settings';
import type { AddPathRequest } from './settings';
import { stackIntercept } from '@protobuf-ts/runtime-rpc';
import type { SettingsData } from './settings';
import type { Empty } from './google/protobuf/empty';
import type { UnaryCall } from '@protobuf-ts/runtime-rpc';
import type { RpcOptions } from '@protobuf-ts/runtime-rpc';
import type { RpcTransport } from "@protobuf-ts/runtime-rpc";
import type { ServiceInfo } from "@protobuf-ts/runtime-rpc";
import { Settings } from "./settings";
import type { RefreshPathResponse } from "./settings";
import type { RefreshPathRequest } from "./settings";
import type { DeletePathResponse } from "./settings";
import type { DeletePathRequest } from "./settings";
import type { AddPathResponse } from "./settings";
import type { AddPathRequest } from "./settings";
import { stackIntercept } from "@protobuf-ts/runtime-rpc";
import type { SettingsData } from "./settings";
import type { Empty } from "./google/protobuf/empty";
import type { UnaryCall } from "@protobuf-ts/runtime-rpc";
import type { RpcOptions } from "@protobuf-ts/runtime-rpc";
/**
* @generated from protobuf service settings.Settings
*/
export interface ISettingsClient {
/**
* @generated from protobuf rpc: ListPaths(google.protobuf.Empty) returns (settings.SettingsData);
*/
listPaths(input: Empty, options?: RpcOptions): UnaryCall<Empty, SettingsData>;
/**
* @generated from protobuf rpc: AddPath(settings.AddPathRequest) returns (settings.AddPathResponse);
*/
addPath(input: AddPathRequest, options?: RpcOptions): UnaryCall<AddPathRequest, AddPathResponse>;
/**
* @generated from protobuf rpc: DeletePath(settings.DeletePathRequest) returns (settings.DeletePathResponse);
*/
deletePath(
input: DeletePathRequest,
options?: RpcOptions
): UnaryCall<DeletePathRequest, DeletePathResponse>;
/**
* @generated from protobuf rpc: RefreshPath(settings.RefreshPathRequest) returns (settings.RefreshPathResponse);
*/
refreshPath(
input: RefreshPathRequest,
options?: RpcOptions
): UnaryCall<RefreshPathRequest, RefreshPathResponse>;
/**
* @generated from protobuf rpc: ListPaths(google.protobuf.Empty) returns (settings.SettingsData);
*/
listPaths(input: Empty, options?: RpcOptions): UnaryCall<Empty, SettingsData>;
/**
* @generated from protobuf rpc: AddPath(settings.AddPathRequest) returns (settings.AddPathResponse);
*/
addPath(input: AddPathRequest, options?: RpcOptions): UnaryCall<AddPathRequest, AddPathResponse>;
/**
* @generated from protobuf rpc: DeletePath(settings.DeletePathRequest) returns (settings.DeletePathResponse);
*/
deletePath(input: DeletePathRequest, options?: RpcOptions): UnaryCall<DeletePathRequest, DeletePathResponse>;
/**
* @generated from protobuf rpc: RefreshPath(settings.RefreshPathRequest) returns (settings.RefreshPathResponse);
*/
refreshPath(input: RefreshPathRequest, options?: RpcOptions): UnaryCall<RefreshPathRequest, RefreshPathResponse>;
}
/**
* @generated from protobuf service settings.Settings
*/
export class SettingsClient implements ISettingsClient, ServiceInfo {
typeName = Settings.typeName;
methods = Settings.methods;
options = Settings.options;
constructor(private readonly _transport: RpcTransport) {}
/**
* @generated from protobuf rpc: ListPaths(google.protobuf.Empty) returns (settings.SettingsData);
*/
listPaths(input: Empty, options?: RpcOptions): UnaryCall<Empty, SettingsData> {
const method = this.methods[0],
opt = this._transport.mergeOptions(options);
return stackIntercept<Empty, SettingsData>('unary', this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: AddPath(settings.AddPathRequest) returns (settings.AddPathResponse);
*/
addPath(input: AddPathRequest, options?: RpcOptions): UnaryCall<AddPathRequest, AddPathResponse> {
const method = this.methods[1],
opt = this._transport.mergeOptions(options);
return stackIntercept<AddPathRequest, AddPathResponse>(
'unary',
this._transport,
method,
opt,
input
);
}
/**
* @generated from protobuf rpc: DeletePath(settings.DeletePathRequest) returns (settings.DeletePathResponse);
*/
deletePath(
input: DeletePathRequest,
options?: RpcOptions
): UnaryCall<DeletePathRequest, DeletePathResponse> {
const method = this.methods[2],
opt = this._transport.mergeOptions(options);
return stackIntercept<DeletePathRequest, DeletePathResponse>(
'unary',
this._transport,
method,
opt,
input
);
}
/**
* @generated from protobuf rpc: RefreshPath(settings.RefreshPathRequest) returns (settings.RefreshPathResponse);
*/
refreshPath(
input: RefreshPathRequest,
options?: RpcOptions
): UnaryCall<RefreshPathRequest, RefreshPathResponse> {
const method = this.methods[3],
opt = this._transport.mergeOptions(options);
return stackIntercept<RefreshPathRequest, RefreshPathResponse>(
'unary',
this._transport,
method,
opt,
input
);
}
typeName = Settings.typeName;
methods = Settings.methods;
options = Settings.options;
constructor(private readonly _transport: RpcTransport) {
}
/**
* @generated from protobuf rpc: ListPaths(google.protobuf.Empty) returns (settings.SettingsData);
*/
listPaths(input: Empty, options?: RpcOptions): UnaryCall<Empty, SettingsData> {
const method = this.methods[0], opt = this._transport.mergeOptions(options);
return stackIntercept<Empty, SettingsData>("unary", this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: AddPath(settings.AddPathRequest) returns (settings.AddPathResponse);
*/
addPath(input: AddPathRequest, options?: RpcOptions): UnaryCall<AddPathRequest, AddPathResponse> {
const method = this.methods[1], opt = this._transport.mergeOptions(options);
return stackIntercept<AddPathRequest, AddPathResponse>("unary", this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: DeletePath(settings.DeletePathRequest) returns (settings.DeletePathResponse);
*/
deletePath(input: DeletePathRequest, options?: RpcOptions): UnaryCall<DeletePathRequest, DeletePathResponse> {
const method = this.methods[2], opt = this._transport.mergeOptions(options);
return stackIntercept<DeletePathRequest, DeletePathResponse>("unary", this._transport, method, opt, input);
}
/**
* @generated from protobuf rpc: RefreshPath(settings.RefreshPathRequest) returns (settings.RefreshPathResponse);
*/
refreshPath(input: RefreshPathRequest, options?: RpcOptions): UnaryCall<RefreshPathRequest, RefreshPathResponse> {
const method = this.methods[3], opt = this._transport.mergeOptions(options);
return stackIntercept<RefreshPathRequest, RefreshPathResponse>("unary", this._transport, method, opt, input);
}
}

View File

@@ -1,153 +1,127 @@
// @generated by protobuf-ts 2.9.4
// @generated from protobuf file "settings.proto" (package "settings", syntax proto3)
// tslint:disable
import { Empty } from './google/protobuf/empty';
import { ServiceType } from '@protobuf-ts/runtime-rpc';
import type { BinaryWriteOptions } from '@protobuf-ts/runtime';
import type { IBinaryWriter } from '@protobuf-ts/runtime';
import { WireType } from '@protobuf-ts/runtime';
import type { BinaryReadOptions } from '@protobuf-ts/runtime';
import type { IBinaryReader } from '@protobuf-ts/runtime';
import { UnknownFieldHandler } from '@protobuf-ts/runtime';
import type { PartialMessage } from '@protobuf-ts/runtime';
import { reflectionMergePartial } from '@protobuf-ts/runtime';
import { MessageType } from '@protobuf-ts/runtime';
import { Empty } from "./google/protobuf/empty";
import { ServiceType } from "@protobuf-ts/runtime-rpc";
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
import type { IBinaryWriter } from "@protobuf-ts/runtime";
import { WireType } from "@protobuf-ts/runtime";
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
import type { IBinaryReader } from "@protobuf-ts/runtime";
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
import type { PartialMessage } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
/**
* @generated from protobuf message settings.SettingsData
*/
export interface SettingsData {
/**
* @generated from protobuf field: repeated settings.LibraryPath library_paths = 1;
*/
libraryPaths: LibraryPath[];
/**
* @generated from protobuf field: repeated settings.LibraryPath library_paths = 1;
*/
libraryPaths: LibraryPath[];
}
/**
* @generated from protobuf message settings.LibraryPath
*/
export interface LibraryPath {
/**
* @generated from protobuf field: uint64 id = 1;
*/
id: bigint;
/**
* @generated from protobuf field: string path = 2;
*/
path: string;
/**
* @generated from protobuf field: uint64 id = 1;
*/
id: bigint;
/**
* @generated from protobuf field: string path = 2;
*/
path: string;
}
/**
* @generated from protobuf message settings.AddPathRequest
*/
export interface AddPathRequest {
/**
* @generated from protobuf field: string path = 1;
*/
path: string;
/**
* @generated from protobuf field: string path = 1;
*/
path: string;
}
/**
* @generated from protobuf message settings.AddPathResponse
*/
export interface AddPathResponse {
/**
* @generated from protobuf field: uint64 id = 1;
*/
id: bigint;
/**
* @generated from protobuf field: uint64 id = 1;
*/
id: bigint;
}
/**
* @generated from protobuf message settings.DeletePathRequest
*/
export interface DeletePathRequest {
/**
* @generated from protobuf field: uint64 id = 1;
*/
id: bigint;
/**
* @generated from protobuf field: uint64 id = 1;
*/
id: bigint;
}
/**
* @generated from protobuf message settings.DeletePathResponse
*/
export interface DeletePathResponse {}
export interface DeletePathResponse {
}
/**
* @generated from protobuf message settings.RefreshPathRequest
*/
export interface RefreshPathRequest {
/**
* @generated from protobuf field: uint64 id = 1;
*/
id: bigint;
/**
* @generated from protobuf field: uint64 id = 1;
*/
id: bigint;
}
/**
* @generated from protobuf message settings.RefreshPathResponse
*/
export interface RefreshPathResponse {}
export interface RefreshPathResponse {
}
// @generated message type with reflection information, may provide speed optimized methods
class SettingsData$Type extends MessageType<SettingsData> {
constructor() {
super('settings.SettingsData', [
{
no: 1,
name: 'library_paths',
kind: 'message',
repeat: 1 /*RepeatType.PACKED*/,
T: () => LibraryPath
}
]);
}
create(value?: PartialMessage<SettingsData>): SettingsData {
const message = globalThis.Object.create(this.messagePrototype!);
message.libraryPaths = [];
if (value !== undefined) reflectionMergePartial<SettingsData>(this, message, value);
return message;
}
internalBinaryRead(
reader: IBinaryReader,
length: number,
options: BinaryReadOptions,
target?: SettingsData
): SettingsData {
let message = target ?? this.create(),
end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* repeated settings.LibraryPath library_paths */ 1:
message.libraryPaths.push(
LibraryPath.internalBinaryRead(reader, reader.uint32(), options)
);
break;
default:
let u = options.readUnknownField;
if (u === 'throw')
throw new globalThis.Error(
`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(
this.typeName,
message,
fieldNo,
wireType,
d
);
}
}
return message;
}
internalBinaryWrite(
message: SettingsData,
writer: IBinaryWriter,
options: BinaryWriteOptions
): IBinaryWriter {
/* repeated settings.LibraryPath library_paths = 1; */
for (let i = 0; i < message.libraryPaths.length; i++)
LibraryPath.internalBinaryWrite(
message.libraryPaths[i],
writer.tag(1, WireType.LengthDelimited).fork(),
options
).join();
let u = options.writeUnknownFields;
if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
constructor() {
super("settings.SettingsData", [
{ no: 1, name: "library_paths", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => LibraryPath }
]);
}
create(value?: PartialMessage<SettingsData>): SettingsData {
const message = globalThis.Object.create((this.messagePrototype!));
message.libraryPaths = [];
if (value !== undefined)
reflectionMergePartial<SettingsData>(this, message, value);
return message;
}
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: SettingsData): SettingsData {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* repeated settings.LibraryPath library_paths */ 1:
message.libraryPaths.push(LibraryPath.internalBinaryRead(reader, reader.uint32(), options));
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message: SettingsData, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* repeated settings.LibraryPath library_paths = 1; */
for (let i = 0; i < message.libraryPaths.length; i++)
LibraryPath.internalBinaryWrite(message.libraryPaths[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join();
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message settings.SettingsData
@@ -155,68 +129,54 @@ class SettingsData$Type extends MessageType<SettingsData> {
export const SettingsData = new SettingsData$Type();
// @generated message type with reflection information, may provide speed optimized methods
class LibraryPath$Type extends MessageType<LibraryPath> {
constructor() {
super('settings.LibraryPath', [
{ no: 1, name: 'id', kind: 'scalar', T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 2, name: 'path', kind: 'scalar', T: 9 /*ScalarType.STRING*/ }
]);
}
create(value?: PartialMessage<LibraryPath>): LibraryPath {
const message = globalThis.Object.create(this.messagePrototype!);
message.id = 0n;
message.path = '';
if (value !== undefined) reflectionMergePartial<LibraryPath>(this, message, value);
return message;
}
internalBinaryRead(
reader: IBinaryReader,
length: number,
options: BinaryReadOptions,
target?: LibraryPath
): LibraryPath {
let message = target ?? this.create(),
end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* uint64 id */ 1:
message.id = reader.uint64().toBigInt();
break;
case /* string path */ 2:
message.path = reader.string();
break;
default:
let u = options.readUnknownField;
if (u === 'throw')
throw new globalThis.Error(
`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(
this.typeName,
message,
fieldNo,
wireType,
d
);
}
}
return message;
}
internalBinaryWrite(
message: LibraryPath,
writer: IBinaryWriter,
options: BinaryWriteOptions
): IBinaryWriter {
/* uint64 id = 1; */
if (message.id !== 0n) writer.tag(1, WireType.Varint).uint64(message.id);
/* string path = 2; */
if (message.path !== '') writer.tag(2, WireType.LengthDelimited).string(message.path);
let u = options.writeUnknownFields;
if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
constructor() {
super("settings.LibraryPath", [
{ no: 1, name: "id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 2, name: "path", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
]);
}
create(value?: PartialMessage<LibraryPath>): LibraryPath {
const message = globalThis.Object.create((this.messagePrototype!));
message.id = 0n;
message.path = "";
if (value !== undefined)
reflectionMergePartial<LibraryPath>(this, message, value);
return message;
}
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: LibraryPath): LibraryPath {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* uint64 id */ 1:
message.id = reader.uint64().toBigInt();
break;
case /* string path */ 2:
message.path = reader.string();
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message: LibraryPath, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* uint64 id = 1; */
if (message.id !== 0n)
writer.tag(1, WireType.Varint).uint64(message.id);
/* string path = 2; */
if (message.path !== "")
writer.tag(2, WireType.LengthDelimited).string(message.path);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message settings.LibraryPath
@@ -224,61 +184,46 @@ class LibraryPath$Type extends MessageType<LibraryPath> {
export const LibraryPath = new LibraryPath$Type();
// @generated message type with reflection information, may provide speed optimized methods
class AddPathRequest$Type extends MessageType<AddPathRequest> {
constructor() {
super('settings.AddPathRequest', [
{ no: 1, name: 'path', kind: 'scalar', T: 9 /*ScalarType.STRING*/ }
]);
}
create(value?: PartialMessage<AddPathRequest>): AddPathRequest {
const message = globalThis.Object.create(this.messagePrototype!);
message.path = '';
if (value !== undefined) reflectionMergePartial<AddPathRequest>(this, message, value);
return message;
}
internalBinaryRead(
reader: IBinaryReader,
length: number,
options: BinaryReadOptions,
target?: AddPathRequest
): AddPathRequest {
let message = target ?? this.create(),
end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* string path */ 1:
message.path = reader.string();
break;
default:
let u = options.readUnknownField;
if (u === 'throw')
throw new globalThis.Error(
`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(
this.typeName,
message,
fieldNo,
wireType,
d
);
}
}
return message;
}
internalBinaryWrite(
message: AddPathRequest,
writer: IBinaryWriter,
options: BinaryWriteOptions
): IBinaryWriter {
/* string path = 1; */
if (message.path !== '') writer.tag(1, WireType.LengthDelimited).string(message.path);
let u = options.writeUnknownFields;
if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
constructor() {
super("settings.AddPathRequest", [
{ no: 1, name: "path", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
]);
}
create(value?: PartialMessage<AddPathRequest>): AddPathRequest {
const message = globalThis.Object.create((this.messagePrototype!));
message.path = "";
if (value !== undefined)
reflectionMergePartial<AddPathRequest>(this, message, value);
return message;
}
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: AddPathRequest): AddPathRequest {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* string path */ 1:
message.path = reader.string();
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message: AddPathRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* string path = 1; */
if (message.path !== "")
writer.tag(1, WireType.LengthDelimited).string(message.path);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message settings.AddPathRequest
@@ -286,61 +231,46 @@ class AddPathRequest$Type extends MessageType<AddPathRequest> {
export const AddPathRequest = new AddPathRequest$Type();
// @generated message type with reflection information, may provide speed optimized methods
class AddPathResponse$Type extends MessageType<AddPathResponse> {
constructor() {
super('settings.AddPathResponse', [
{ no: 1, name: 'id', kind: 'scalar', T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }
]);
}
create(value?: PartialMessage<AddPathResponse>): AddPathResponse {
const message = globalThis.Object.create(this.messagePrototype!);
message.id = 0n;
if (value !== undefined) reflectionMergePartial<AddPathResponse>(this, message, value);
return message;
}
internalBinaryRead(
reader: IBinaryReader,
length: number,
options: BinaryReadOptions,
target?: AddPathResponse
): AddPathResponse {
let message = target ?? this.create(),
end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* uint64 id */ 1:
message.id = reader.uint64().toBigInt();
break;
default:
let u = options.readUnknownField;
if (u === 'throw')
throw new globalThis.Error(
`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(
this.typeName,
message,
fieldNo,
wireType,
d
);
}
}
return message;
}
internalBinaryWrite(
message: AddPathResponse,
writer: IBinaryWriter,
options: BinaryWriteOptions
): IBinaryWriter {
/* uint64 id = 1; */
if (message.id !== 0n) writer.tag(1, WireType.Varint).uint64(message.id);
let u = options.writeUnknownFields;
if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
constructor() {
super("settings.AddPathResponse", [
{ no: 1, name: "id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }
]);
}
create(value?: PartialMessage<AddPathResponse>): AddPathResponse {
const message = globalThis.Object.create((this.messagePrototype!));
message.id = 0n;
if (value !== undefined)
reflectionMergePartial<AddPathResponse>(this, message, value);
return message;
}
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: AddPathResponse): AddPathResponse {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* uint64 id */ 1:
message.id = reader.uint64().toBigInt();
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message: AddPathResponse, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* uint64 id = 1; */
if (message.id !== 0n)
writer.tag(1, WireType.Varint).uint64(message.id);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message settings.AddPathResponse
@@ -348,61 +278,46 @@ class AddPathResponse$Type extends MessageType<AddPathResponse> {
export const AddPathResponse = new AddPathResponse$Type();
// @generated message type with reflection information, may provide speed optimized methods
class DeletePathRequest$Type extends MessageType<DeletePathRequest> {
constructor() {
super('settings.DeletePathRequest', [
{ no: 1, name: 'id', kind: 'scalar', T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }
]);
}
create(value?: PartialMessage<DeletePathRequest>): DeletePathRequest {
const message = globalThis.Object.create(this.messagePrototype!);
message.id = 0n;
if (value !== undefined) reflectionMergePartial<DeletePathRequest>(this, message, value);
return message;
}
internalBinaryRead(
reader: IBinaryReader,
length: number,
options: BinaryReadOptions,
target?: DeletePathRequest
): DeletePathRequest {
let message = target ?? this.create(),
end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* uint64 id */ 1:
message.id = reader.uint64().toBigInt();
break;
default:
let u = options.readUnknownField;
if (u === 'throw')
throw new globalThis.Error(
`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(
this.typeName,
message,
fieldNo,
wireType,
d
);
}
}
return message;
}
internalBinaryWrite(
message: DeletePathRequest,
writer: IBinaryWriter,
options: BinaryWriteOptions
): IBinaryWriter {
/* uint64 id = 1; */
if (message.id !== 0n) writer.tag(1, WireType.Varint).uint64(message.id);
let u = options.writeUnknownFields;
if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
constructor() {
super("settings.DeletePathRequest", [
{ no: 1, name: "id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }
]);
}
create(value?: PartialMessage<DeletePathRequest>): DeletePathRequest {
const message = globalThis.Object.create((this.messagePrototype!));
message.id = 0n;
if (value !== undefined)
reflectionMergePartial<DeletePathRequest>(this, message, value);
return message;
}
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: DeletePathRequest): DeletePathRequest {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* uint64 id */ 1:
message.id = reader.uint64().toBigInt();
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message: DeletePathRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* uint64 id = 1; */
if (message.id !== 0n)
writer.tag(1, WireType.Varint).uint64(message.id);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message settings.DeletePathRequest
@@ -410,31 +325,24 @@ class DeletePathRequest$Type extends MessageType<DeletePathRequest> {
export const DeletePathRequest = new DeletePathRequest$Type();
// @generated message type with reflection information, may provide speed optimized methods
class DeletePathResponse$Type extends MessageType<DeletePathResponse> {
constructor() {
super('settings.DeletePathResponse', []);
}
create(value?: PartialMessage<DeletePathResponse>): DeletePathResponse {
const message = globalThis.Object.create(this.messagePrototype!);
if (value !== undefined) reflectionMergePartial<DeletePathResponse>(this, message, value);
return message;
}
internalBinaryRead(
reader: IBinaryReader,
length: number,
options: BinaryReadOptions,
target?: DeletePathResponse
): DeletePathResponse {
return target ?? this.create();
}
internalBinaryWrite(
message: DeletePathResponse,
writer: IBinaryWriter,
options: BinaryWriteOptions
): IBinaryWriter {
let u = options.writeUnknownFields;
if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
constructor() {
super("settings.DeletePathResponse", []);
}
create(value?: PartialMessage<DeletePathResponse>): DeletePathResponse {
const message = globalThis.Object.create((this.messagePrototype!));
if (value !== undefined)
reflectionMergePartial<DeletePathResponse>(this, message, value);
return message;
}
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: DeletePathResponse): DeletePathResponse {
return target ?? this.create();
}
internalBinaryWrite(message: DeletePathResponse, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message settings.DeletePathResponse
@@ -442,61 +350,46 @@ class DeletePathResponse$Type extends MessageType<DeletePathResponse> {
export const DeletePathResponse = new DeletePathResponse$Type();
// @generated message type with reflection information, may provide speed optimized methods
class RefreshPathRequest$Type extends MessageType<RefreshPathRequest> {
constructor() {
super('settings.RefreshPathRequest', [
{ no: 1, name: 'id', kind: 'scalar', T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }
]);
}
create(value?: PartialMessage<RefreshPathRequest>): RefreshPathRequest {
const message = globalThis.Object.create(this.messagePrototype!);
message.id = 0n;
if (value !== undefined) reflectionMergePartial<RefreshPathRequest>(this, message, value);
return message;
}
internalBinaryRead(
reader: IBinaryReader,
length: number,
options: BinaryReadOptions,
target?: RefreshPathRequest
): RefreshPathRequest {
let message = target ?? this.create(),
end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* uint64 id */ 1:
message.id = reader.uint64().toBigInt();
break;
default:
let u = options.readUnknownField;
if (u === 'throw')
throw new globalThis.Error(
`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(
this.typeName,
message,
fieldNo,
wireType,
d
);
}
}
return message;
}
internalBinaryWrite(
message: RefreshPathRequest,
writer: IBinaryWriter,
options: BinaryWriteOptions
): IBinaryWriter {
/* uint64 id = 1; */
if (message.id !== 0n) writer.tag(1, WireType.Varint).uint64(message.id);
let u = options.writeUnknownFields;
if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
constructor() {
super("settings.RefreshPathRequest", [
{ no: 1, name: "id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }
]);
}
create(value?: PartialMessage<RefreshPathRequest>): RefreshPathRequest {
const message = globalThis.Object.create((this.messagePrototype!));
message.id = 0n;
if (value !== undefined)
reflectionMergePartial<RefreshPathRequest>(this, message, value);
return message;
}
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: RefreshPathRequest): RefreshPathRequest {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* uint64 id */ 1:
message.id = reader.uint64().toBigInt();
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message: RefreshPathRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* uint64 id = 1; */
if (message.id !== 0n)
writer.tag(1, WireType.Varint).uint64(message.id);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message settings.RefreshPathRequest
@@ -504,31 +397,24 @@ class RefreshPathRequest$Type extends MessageType<RefreshPathRequest> {
export const RefreshPathRequest = new RefreshPathRequest$Type();
// @generated message type with reflection information, may provide speed optimized methods
class RefreshPathResponse$Type extends MessageType<RefreshPathResponse> {
constructor() {
super('settings.RefreshPathResponse', []);
}
create(value?: PartialMessage<RefreshPathResponse>): RefreshPathResponse {
const message = globalThis.Object.create(this.messagePrototype!);
if (value !== undefined) reflectionMergePartial<RefreshPathResponse>(this, message, value);
return message;
}
internalBinaryRead(
reader: IBinaryReader,
length: number,
options: BinaryReadOptions,
target?: RefreshPathResponse
): RefreshPathResponse {
return target ?? this.create();
}
internalBinaryWrite(
message: RefreshPathResponse,
writer: IBinaryWriter,
options: BinaryWriteOptions
): IBinaryWriter {
let u = options.writeUnknownFields;
if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
constructor() {
super("settings.RefreshPathResponse", []);
}
create(value?: PartialMessage<RefreshPathResponse>): RefreshPathResponse {
const message = globalThis.Object.create((this.messagePrototype!));
if (value !== undefined)
reflectionMergePartial<RefreshPathResponse>(this, message, value);
return message;
}
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: RefreshPathResponse): RefreshPathResponse {
return target ?? this.create();
}
internalBinaryWrite(message: RefreshPathResponse, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message settings.RefreshPathResponse
@@ -537,9 +423,9 @@ export const RefreshPathResponse = new RefreshPathResponse$Type();
/**
* @generated ServiceType for protobuf service settings.Settings
*/
export const Settings = new ServiceType('settings.Settings', [
{ name: 'ListPaths', options: {}, I: Empty, O: SettingsData },
{ name: 'AddPath', options: {}, I: AddPathRequest, O: AddPathResponse },
{ name: 'DeletePath', options: {}, I: DeletePathRequest, O: DeletePathResponse },
{ name: 'RefreshPath', options: {}, I: RefreshPathRequest, O: RefreshPathResponse }
export const Settings = new ServiceType("settings.Settings", [
{ name: "ListPaths", options: {}, I: Empty, O: SettingsData },
{ name: "AddPath", options: {}, I: AddPathRequest, O: AddPathResponse },
{ name: "DeletePath", options: {}, I: DeletePathRequest, O: DeletePathResponse },
{ name: "RefreshPath", options: {}, I: RefreshPathRequest, O: RefreshPathResponse }
]);

View File

@@ -2,8 +2,30 @@ import { PlayerClient } from '$lib/proto/player.client';
import { fail } from '@sveltejs/kit';
import { protoTransport } from '../../hooks.server';
import type { Actions } from './$types';
import { serializable } from '$lib/proto';
import type { PlayerStatus } from '$lib/proto/player';
export const actions = {
skip: async () => {
const client = new PlayerClient(protoTransport);
const response = await client.skipTrack({});
return serializable<PlayerStatus>(response.response);
},
'skip-to-queue-index': async ({ url }) => {
const index = url.searchParams.get('index')?.toString();
if (!index) {
return fail(400);
}
const client = new PlayerClient(protoTransport);
const response = await client.skipToQueueIndex({ index: parseInt(index) });
return serializable<PlayerStatus>(response.response);
},
resume: async () => {
const client = new PlayerClient(protoTransport);

View File

@@ -3,7 +3,7 @@ import { fail } from '@sveltejs/kit';
import { protoTransport } from '../../../hooks.server';
import type { Actions } from './$types';
import { serializable } from '$lib/proto';
import type { PlayTrackResponse } from '$lib/proto/player';
import type { PlayTrackResponse, Queue } from '$lib/proto/player';
export const actions = {
play: async ({ params }) => {
@@ -18,5 +18,23 @@ export const actions = {
}
return serializable<PlayTrackResponse>(response.response);
},
'add-to-queue': async ({ params }) => {
const client = new PlayerClient(protoTransport);
const response = await client.addTrackToQueue({
hash: params.hash
});
return serializable<Queue>(response.response);
},
'play-next': async ({ params }) => {
const client = new PlayerClient(protoTransport);
const response = await client.playTrackNext({
hash: params.hash
});
return serializable<Queue>(response.response);
}
} satisfies Actions;