Fresh start (#110)

* Fresh start

* Create an xml include plugin (#111)

* Restructure and add testing (#114)

* rooibos setup

* Restructure and add testing

* docs

* Restore manifestpipi

* Description in tools

* A bit of docs

* Auto bind feature (#115)

* Auto bind feature

* Fix children merge

* bs plugin fix

* Feature/app controller (#120)

* Initial layout

* Restructuring and plugin work

* A couple of tweaks in binding stuff

* tweaks

* basic stack

* Add basic app controller

* Support json5/yaml in playlet config files (#123)

* Support json5 in playlet config files

* Add yaml to the mix

* Delete old lib project

* plugin fix

* plugin tweak

* verbose logging

* Revert "verbose logging"

This reverts commit 25867f4226703d83102519a0d48d1cc46a9876de.

* One idea to fix the include plugin

* Fix instability in plugins

* Feature/navbar (#126)

* Navbar

* typo

* comment

* Single content node, and tests

* Remove unused field

* tweaks

* update dependencies command

* tweak formatting

* Add web app screen

* Set id in created screens

* Search screen

* Tests

* Show playlists and channels in search results

* Move screen stuff to app controller

* Home screen (wip)

* Add preferences node

* README.md copyedits (#130)

* README.md: Fix typos

* README.md: Standardize capitalization and punctuation

* Update docs/README.md

---------

Co-authored-by: Brahim Hadriche <brahim.hadriche@gmail.com>

* Web server: round 1 (#131)

* web server object

* Logging

* Web server round 1

* Lint fix

* Small tweaks

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>

* Logging to file

* Leftover

* Add logs file to web server

* Fix for timeout

* Disable keepalive connection

* add openapi spec file

* Lint fix

* add prefs version in api

* Add ecp api definition

* Lint fix

* Settings rework (#135)

* Settings rework

* Standard OnFocusChange event

* Video player stuff (#136)

* Video player stuff

* Restructure things so that focus is better handled

* Lint fix

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>

* Exit dialog

* A bunch of changes

* New http client

* Set TODO priorities

* picture in picture

* mark video watched

* Video player stuff mostly there

* update spec file

* Sponsorblock

* FuncName

* SponsorBlock notifications

* Lint fix

* misc

* remove basic auth feature flag (until we start using it)

* Play queue part 1

* type fix

* handle unicode in request body

* SponsorBlock chapter label

* modal base

* remove a hack

* Invidious settings

* web server reduce timeout

* Test for captions

* Lint fix

* remove rpc stuff

* small change

* Solve focus management

* a couple of fixes

* Remove a bunch of todos

* feed error handling wip

* Lint fix

* navigation in instance settings

* home screen pagination support

* Refactor feed to support pagination on search page

* cell loading animation

* Tweak caching

* delete test screen

* playlist support part 1

* Basic playlist view

* Restore playlist/channel handler

* Refactor some content node stuff, and add an auth popup dialog

* A bad implementation of a playqueue

* Lint fix

* playlist cast fix

* Feature/web app catch up (#139)

* playlist cast fix

* Move things around

* support playlists in web app

* update api

* Bump deps

* Downgrade todo

---------

Co-authored-by: Bryce Harrington <bryce@bryceharrington.org>
Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
authored and GitHub committed 2023-09-07 17:18:25 -04:00
1 parent 79f74141c5
commit 43166fb43b
349 files changed
+12784 -7660

No files matched your search

File renamed without changes.
@@ -1,4 +1,4 @@
import { PlayletApi } from "./PlayletApi";
import { PlayletApi } from "lib/Api/PlayletApi";
export class InvidiousApi {
public instance: string;
@@ -9,7 +9,7 @@ export class InvidiousApi {
responseHandlers: any;
constructor() {
// Note: AuthFeedHandler and AuthPlaylistsHandler are not needed, since it is handled server side
// Note: handlers for authenticated requests are not needed, since they are handled server side
this.responseHandlers = {
"DefaultHandler": (requestData, response) => this.DefaultHandler(requestData, response),
"PlaylistHandler": (requestData, response) => this.PlaylistHandler(requestData, response),
@@ -57,14 +57,14 @@ export class InvidiousApi {
for (let queryParamKey in endpoint.queryParams) {
let queryParam = endpoint.queryParams[queryParamKey];
if (queryParam.default !== undefined) {
if (queryParam.type === "string") {
queryParams[queryParamKey] = queryParam.default;
} else if (queryParam.type === "#ISO3166") {
if (queryParam.type === "#ISO3166") {
if (queryParam.default === "GetUserCountryCode") {
queryParams[queryParamKey] = this.userCountryCode;
} else {
queryParams[queryParamKey] = queryParam.default;
}
} else {
queryParams[queryParamKey] = queryParam.default;
}
}
}
@@ -76,7 +76,7 @@ export class InvidiousApi {
if (requestData.pathParams !== undefined) {
for (let param in requestData.pathParams) {
url = url.replace(`:${param}`, requestData.pathParams[param]);
url = url.replace(`{${param}}`, requestData.pathParams[param]);
}
}
@@ -91,26 +91,12 @@ export class InvidiousApi {
}
private async DefaultHandler(requestData, response) {
const json = await response.json();
return [{ title: requestData.title, videos: json }]
return await response.json();
}
private async PlaylistHandler(requestData, response) {
const playlist = await response.json();
return [this.ProcessPlaylist(requestData, playlist)]
}
private ProcessPlaylist(requestData, playlist) {
const title = this.ProcessTemplate(requestData.title, playlist)
return { title: title, videos: playlist.videos }
}
private ProcessTemplate(template: string, data) {
let result = template;
for (let key in data) {
result = result.replace(`%${key}%`, `${data[key]}`);
}
return result;
return playlist.videos
}
private makeUrl(url: string, params: any) {
@@ -1,4 +1,4 @@
import { getHost } from "./Host";
import { getHost } from "lib/Api/Host";
export class PlayletApi {
static host = () => `http://${getHost()}`
@@ -9,17 +9,17 @@ export class PlayletApi {
}
static async getPreferencesFile() {
const response = await fetch(`${PlayletApi.host()}/config/preferences.json`);
const response = await fetch(`${PlayletApi.host()}/config/preferences.json5`);
return await response.json();
}
static async getHomeLayoutFile() {
const response = await fetch(`${PlayletApi.host()}/config/default_home_layout.json`);
const response = await fetch(`${PlayletApi.host()}/config/default_home_layout.json5`);
return await response.json();
}
static async getInvidiousVideoApiFile() {
const response = await fetch(`${PlayletApi.host()}/config/invidious_video_api.json`);
const response = await fetch(`${PlayletApi.host()}/config/invidious_video_api.json5`);
return await response.json();
}
@@ -40,18 +40,78 @@ export class PlayletApi {
}
static async logout() {
return await PlayletApi.postJson(`${PlayletApi.host()}/api/command`, { command: "logout" });
await fetch(`${PlayletApi.host()}/invidious/logout`);
}
static async playVideo(videoId, timestamp) {
static async playVideo(videoId, timestamp, title, author) {
if (!videoId) {
return;
}
const payload = { command: "play", videoId: videoId };
const args = { videoId };
if (timestamp !== undefined) {
payload["timestamp"] = timestamp;
if (typeof timestamp === "string") {
timestamp = parseInt(timestamp);
}
args["timestamp"] = timestamp;
}
return await PlayletApi.postJson(`${PlayletApi.host()}/api/command`, payload);
if (title !== undefined) {
args["title"] = title;
}
if (author !== undefined) {
args["author"] = author;
}
await PlayletApi.postJson(`${PlayletApi.host()}/api/queue/play`, args);
}
static async playPlaylist(playlistId, title, videoCount) {
if (!playlistId) {
return;
}
const args = { playlistId };
if (title !== undefined) {
args["title"] = title;
}
if (videoCount !== undefined) {
args["author"] = videoCount;
}
await PlayletApi.postJson(`${PlayletApi.host()}/api/queue/play`, args);
}
static async queueVideo(videoId, timestamp, title, author) {
if (!videoId) {
return;
}
const args = { videoId };
if (timestamp !== undefined) {
if (typeof timestamp === "string") {
timestamp = parseInt(timestamp);
}
args["timestamp"] = timestamp;
}
if (title !== undefined) {
args["title"] = title;
}
if (author !== undefined) {
args["author"] = author;
}
const response = await PlayletApi.postJson(`${PlayletApi.host()}/api/queue`, args);
return await response.json();
}
static async queuePlaylist(playlistId, title, videoCount) {
if (!playlistId) {
return;
}
const args = { playlistId };
if (title !== undefined) {
args["title"] = title;
}
if (videoCount !== undefined) {
args["author"] = videoCount;
}
const response = await PlayletApi.postJson(`${PlayletApi.host()}/api/queue`, args);
return await response.json();
}
static async getSearchHistory() {
@@ -73,16 +133,15 @@ export class PlayletApi {
}
static async setPlayletLibVersion(tag) {
let content = null
if (tag !== "") {
content = JSON.stringify([{
const urls = [{
link: `https://github.com/iBicha/playlet/releases/download/${tag}/playlet-lib.zip`,
type: 'custom'
}]);
}]
await PlayletApi.postJson(`${PlayletApi.host()}/api/playlet-lib-urls`, urls);
} else {
return await fetch(`${PlayletApi.host()}/api/playlet-lib-urls`, { method: "DELETE" });
}
await this.postJson(`${PlayletApi.host()}/api/command`, { command: "set-playlet-lib-urls", content: content });
}
private static postJson(url, payload) {
+2 -2
View File
@@ -3,8 +3,8 @@
import InfoIcon from "../assets/info-icon.svg.svelte";
import SearchIcon from "../assets/search-icon.svg.svelte";
import SettingsIcon from "../assets/settings-icon.svg.svelte";
import { appStateStore } from "./Stores";
import type { AppState } from "./Types";
import { appStateStore } from "lib/Stores";
import type { AppState } from "lib/Types";
function setScreen(screen: AppState["screen"]) {
appStateStore.update((state) => {
+21 -5
View File
@@ -1,9 +1,9 @@
<script lang="ts">
import { onDestroy, onMount } from "svelte";
import { PlayletApi } from "./PlayletApi";
import { playletStateStore } from "./Stores";
import { InvidiousApi } from "./InvidiousApi";
import VideoStartAt from "./VideoStartAt.svelte";
import { PlayletApi } from "lib/Api/PlayletApi";
import { playletStateStore } from "lib/Stores";
import { InvidiousApi } from "lib/Api/InvidiousApi";
import VideoStartAt from "lib/VideoStartAt.svelte";
let modal;
let isDragging;
@@ -146,7 +146,20 @@
}
async function playVideoOnTv() {
await PlayletApi.playVideo(videoMetadata?.videoId, videoStartAtTimestamp);
await PlayletApi.playVideo(
videoMetadata?.videoId,
videoStartAtTimestamp,
videoMetadata?.title,
videoMetadata?.author
);
}
async function queueVideoOnTv() {
await PlayletApi.queueVideo(
videoMetadata?.videoId,
videoStartAtTimestamp,
videoMetadata?.title,
videoMetadata?.author
);
}
function openInvidiousInNewTab() {
@@ -180,6 +193,9 @@
lengthSeconds={videoMetadata?.lengthSeconds}
/>
<button class="btn m-2" on:click={playVideoOnTv}>Play on {tvName}</button>
<button class="btn m-2" on:click={queueVideoOnTv}
>Queue on {tvName}
</button>
<button class="btn m-2" on:click={openInvidiousInNewTab}
>Open in Invidious</button
>
+6 -6
View File
@@ -1,10 +1,10 @@
<script lang="ts">
import playletLogoDark from "../assets/logo-dark.svg";
import playletLogoLight from "../assets/logo-light.svg";
import UserIcon from "../assets/user.svg.svelte";
import { PlayletApi } from "./PlayletApi";
import { appThemeStore, playletStateStore } from "./Stores";
import ThemeSelect from "./ThemeToggle.svelte";
import playletLogoDark from "assets/logo-dark.svg";
import playletLogoLight from "assets/logo-light.svg";
import UserIcon from "assets/user.svg.svelte";
import { PlayletApi } from "lib/Api/PlayletApi";
import { appThemeStore, playletStateStore } from "lib/Stores";
import ThemeSelect from "lib/ThemeToggle.svelte";
let version;
let loggedIn = false;
-82
View File
@@ -1,82 +0,0 @@
<script lang="ts">
import { InvidiousApi } from "./InvidiousApi";
import { invidiousVideoApiStore, playletStateStore } from "./Stores";
import VideoCell from "./VideoCell.svelte";
export let requestData: any = undefined;
export let videoRowData = undefined;
let carouselElement;
let scrollStart = 0;
let scrollEnd = 0;
// w-80 p-2: 320px + 16px padding on each side
const itemWidth = 320 + 16 * 2;
$: {
if (videoRowData && !Array.isArray(videoRowData)) {
if (
carouselElement &&
videoRowData.videos &&
videoRowData.videos.length
) {
recalculateVisibileCells();
}
}
}
let invidiousApi = new InvidiousApi();
playletStateStore.subscribe((value) => {
invidiousApi.instance = value?.invidious?.current_instance;
invidiousApi.userCountryCode = value?.device?.user_country_code ?? "US";
invidiousApi.isLoggedIn = value.invidious?.logged_in ?? false;
updateRow();
});
invidiousVideoApiStore.subscribe((value) => {
invidiousApi.endpoints = value;
updateRow();
});
async function updateRow() {
const result = await invidiousApi.makeRequest(requestData);
if (result) {
videoRowData = result;
}
}
function recalculateVisibileCells() {
const scrollLeft = carouselElement.scrollLeft;
const clientWidth = carouselElement.clientWidth || window.innerWidth;
scrollStart = Math.floor(scrollLeft / itemWidth) - 1;
scrollEnd = Math.ceil((scrollLeft + clientWidth) / itemWidth) + 1;
}
</script>
{#if videoRowData}
{#if Array.isArray(videoRowData)}
{#each videoRowData as child}
<svelte:self videoRowData={child} />
{/each}
{:else if videoRowData.title && videoRowData.videos}
<div class="text-lg font-semibold m-4">
{videoRowData.title}
</div>
<div
class="carousel carousel-center rounded-box w-full space-x-4"
bind:this={carouselElement}
on:scroll={recalculateVisibileCells}
>
{#each videoRowData.videos as video, i}
<div class="carousel-item w-80 p-2">
{#if i >= scrollStart && i <= scrollEnd}
<VideoCell {...video} />
{/if}
</div>
{/each}
</div>
{/if}
{/if}
-30
View File
@@ -1,30 +0,0 @@
<script lang="ts">
import DevSettings from "./DevSettings.svelte";
import SettingsNode from "./SettingsNode.svelte";
import { preferencesModelStore } from "./Stores";
import { onMount } from "svelte";
export let visibility: boolean;
let developerOptionsEnabled = false;
onMount(async () => {
const urlParams = new URLSearchParams(window.location.search);
developerOptionsEnabled = !!urlParams.get("dev");
});
</script>
<div class={visibility ? "" : "hidden"}>
{#each $preferencesModelStore as pref, i}
{#if pref.visibility !== "tv"}
<SettingsNode {...pref} />
{#if i !== $preferencesModelStore.length - 1}
<div class="divider" />
{/if}
{/if}
{/each}
{#if developerOptionsEnabled}
<div class="divider" />
<DevSettings />
{/if}
</div>
@@ -0,0 +1,107 @@
<script lang="ts">
import { PlayletApi } from "lib/Api/PlayletApi";
import { playletStateStore } from "lib/Stores";
export let title: string | undefined = undefined;
export let author: string | undefined = undefined;
export let playlistId: string | undefined = undefined;
export let playlistThumbnail: string | undefined = undefined;
export let videoCount: number | undefined = undefined;
export let videos: any[] | undefined = undefined;
// svelte-ignore unused-export-let
export let type: string = undefined;
let modal;
let tvName = "Roku TV";
let invidiousInstance;
playletStateStore.subscribe((value) => {
tvName = value?.device?.friendly_name ?? "Roku TV";
invidiousInstance = value?.invidious?.current_instance;
});
function getThumbnailUrl(quality: string = "medium") {
let url = "";
if (playlistThumbnail) {
url = playlistThumbnail;
if (url.startsWith("/") && invidiousInstance) {
url = invidiousInstance + url;
}
} else if (videos && videos.length) {
const video = videos[0];
if (video.videoThumbnails) {
const videoThumbnail =
video.videoThumbnails.find(
(thumbnail) => thumbnail.quality === quality
) || video.videoThumbnails[0];
url = videoThumbnail.url;
}
if (url.startsWith("/") && invidiousInstance) {
url = invidiousInstance + url;
}
}
if (url === "") {
url = `${invidiousInstance}/vi/-----------/mqdefault.jpg`;
}
return url;
}
async function playPlaylistOnTv() {
await PlayletApi.playPlaylist(playlistId, title, videoCount);
}
async function queuePlaylistOnTv() {
await PlayletApi.queuePlaylist(playlistId, title, videoCount);
}
function openInvidiousInNewTab() {
let url = `${invidiousInstance}/playlist?list=${playlistId}`;
window.open(url);
}
</script>
<button class="w-80 p-2" on:click={modal.showModal()}>
<div class="card card-compact bg-base-100 shadow-xl border border-neutral">
<figure class="relative">
<img
class="w-full rounded-box aspect-video object-cover"
loading="lazy"
width="320"
height="180"
src={getThumbnailUrl()}
alt={title}
/>
<div
class="absolute bottom-2 right-0 bg-black/70 text-white text-sm rounded-sm pt-1 pb-1 pr-2 pl-2"
>
{videoCount} videos
</div>
</figure>
<div class="card-body">
<h3 class="card-title text-base line-clamp-2 min-h-12">{title}</h3>
<div class="font-semibold">{author}</div>
</div>
</div>
</button>
<!-- TODO:P2 a dialog for every video is very slow. Need to reuse the same one -->
<dialog bind:this={modal} id="modal_{playlistId}" class="modal">
<form method="dialog" class="modal-box bg-base-100">
<h3 class="text-lg m-5">{title}</h3>
<div class="flex flex-col">
<button class="btn m-2" on:click={playPlaylistOnTv}
>Play on {tvName}</button
>
<button class="btn m-2" on:click={queuePlaylistOnTv}
>Queue on {tvName}
</button>
<button class="btn m-2" on:click={openInvidiousInNewTab}
>Open in Invidious</button
>
<button class="btn m-2">Cancel</button>
</div>
</form>
<form method="dialog" class="modal-backdrop">
<button>close</button>
</form>
</dialog>
@@ -0,0 +1,84 @@
<script lang="ts">
import { InvidiousApi } from "lib/Api/InvidiousApi";
import { invidiousVideoApiStore, playletStateStore } from "lib/Stores";
import VideoCell from "lib/Screens/Home/VideoCell.svelte";
import PlaylistCell from "lib/Screens/Home/PlaylistCell.svelte";
export let requestData: any = undefined;
export let videos = undefined;
let carouselElement;
let scrollStart = 0;
let scrollEnd = 0;
// w-80 p-2: 320px + 16px padding on each side
const itemWidth = 320 + 16 * 2;
$: {
if (carouselElement && videos && videos.length) {
recalculateVisibileCells();
}
}
let invidiousApi = new InvidiousApi();
playletStateStore.subscribe((value) => {
invidiousApi.instance = value?.invidious?.current_instance;
invidiousApi.userCountryCode = value?.device?.user_country_code ?? "US";
invidiousApi.isLoggedIn = value.invidious?.logged_in ?? false;
updateRow();
});
invidiousVideoApiStore.subscribe((value) => {
invidiousApi.endpoints = value;
updateRow();
});
async function updateRow() {
const result = await invidiousApi.makeRequest(requestData);
if (result) {
result.forEach((item) => {
if (item.videoId) {
item.type = "video";
} else if (item.playlistId) {
item.type = "playlist";
}
});
videos = result.filter(
(video) => video.type === "video" || video.type === "playlist"
);
}
}
function recalculateVisibileCells() {
const scrollLeft = carouselElement.scrollLeft;
const clientWidth = carouselElement.clientWidth || window.innerWidth;
scrollStart = Math.floor(scrollLeft / itemWidth) - 1;
scrollEnd = Math.ceil((scrollLeft + clientWidth) / itemWidth) + 1;
}
</script>
{#if videos}
<div class="text-lg font-semibold m-4">
{requestData.title}
</div>
<div
class="carousel carousel-center rounded-box w-full space-x-4"
bind:this={carouselElement}
on:scroll={recalculateVisibileCells}
>
{#each videos as video, i}
<div class="carousel-item w-80 p-2">
{#if i >= scrollStart && i <= scrollEnd}
{#if video.type === "video"}
<VideoCell {...video} />
{:else if video.type === "playlist"}
<PlaylistCell {...video} />
{/if}
{/if}
</div>
{/each}
</div>
{/if}
@@ -1,7 +1,7 @@
<script lang="ts">
import { PlayletApi } from "./PlayletApi";
import { playletStateStore } from "./Stores";
import VideoStartAt from "./VideoStartAt.svelte";
import { PlayletApi } from "lib/Api/PlayletApi";
import { playletStateStore } from "lib/Stores";
import VideoStartAt from "lib/VideoStartAt.svelte";
export let title: string | undefined = undefined;
export let videoId: string | undefined = undefined;
@@ -117,7 +117,11 @@
const videoThumbnail =
videoThumbnails.find((thumbnail) => thumbnail.quality === quality) ||
videoThumbnails[0];
return videoThumbnail.url;
let url = videoThumbnail.url;
if (url.startsWith("/") && invidiousInstance) {
url = invidiousInstance + url;
}
return url;
}
function formatViewCount(viewCount) {
@@ -176,7 +180,11 @@
}
async function playVideoOnTv() {
await PlayletApi.playVideo(videoId, videoStartAtTimestamp);
await PlayletApi.playVideo(videoId, videoStartAtTimestamp, title, author);
}
async function queueVideoOnTv() {
await PlayletApi.queueVideo(videoId, videoStartAtTimestamp, title, author);
}
function openInvidiousInNewTab() {
@@ -220,7 +228,7 @@
</div>
</div>
</button>
<!-- TODO: a dialog for every video is very slow. Need to reuse the same one -->
<!-- TODO:P2 a dialog for every video is very slow. Need to reuse the same one -->
<dialog bind:this={modal} id="modal_{videoId}" class="modal">
<form method="dialog" class="modal-box bg-base-100">
<h3 class="text-lg m-5">{title}</h3>
@@ -231,6 +239,9 @@
{lengthSeconds}
/>
<button class="btn m-2" on:click={playVideoOnTv}>Play on {tvName}</button>
<button class="btn m-2" on:click={queueVideoOnTv}
>Queue on {tvName}
</button>
<button class="btn m-2" on:click={openInvidiousInNewTab}
>Open in Invidious</button
>
@@ -1,6 +1,6 @@
<script lang="ts">
import ScreenHomeRow from "./ScreenHomeRow.svelte";
import { homeLayoutFileStore } from "./Stores";
import ScreenHomeRow from "lib/Screens/Home/ScreenHomeRow.svelte";
import { homeLayoutFileStore } from "lib/Stores";
export let visibility: boolean;
</script>
@@ -1,5 +1,5 @@
<script lang="ts">
import { playletStateStore } from "./Stores";
import { playletStateStore } from "lib/Stores";
export let visibility: boolean;
@@ -1,9 +1,10 @@
<script lang="ts">
import { InvidiousApi } from "./InvidiousApi";
import { PlayletApi } from "./PlayletApi";
import { playletStateStore, searchHistoryStore } from "./Stores";
import VideoCell from "./VideoCell.svelte";
import SearchThinIcon from "../assets/search-thin-icon.svg.svelte";
import { InvidiousApi } from "lib/Api/InvidiousApi";
import { PlayletApi } from "lib/Api/PlayletApi";
import { playletStateStore, searchHistoryStore } from "lib/Stores";
import VideoCell from "lib/Screens/Home/VideoCell.svelte";
import PlaylistCell from "lib/Screens/Home/PlaylistCell.svelte";
import SearchThinIcon from "assets/search-thin-icon.svg.svelte";
export let visibility: boolean;
@@ -153,6 +154,8 @@
{#each videos as video}
{#if video.type === "video"}
<VideoCell {...video} />
{:else if video.type === "playlist"}
<PlaylistCell {...video} />
{/if}
{/each}
</div>
@@ -1,7 +1,7 @@
<script>
import { onMount } from "svelte";
import { PlayletApi } from "./PlayletApi";
import { playletStateStore } from "./Stores";
import { PlayletApi } from "lib/Api/PlayletApi";
import { playletStateStore } from "lib/Stores";
let selectedRelease = "";
let releases = [];
@@ -1,6 +1,6 @@
<script lang="ts">
import { PlayletApi } from "../PlayletApi";
import { userPreferencesStore } from "../Stores";
import { PlayletApi } from "lib/Api/PlayletApi";
import { userPreferencesStore } from "lib/Stores";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
@@ -32,5 +32,5 @@
class="checkbox"
/>
</label>
<div class="text-xs text-gray-500">{description}</div>
<div class="text-xs text-gray-500">{@html description}</div>
</div>
@@ -1,6 +1,6 @@
<script lang="ts">
import { PlayletApi } from "../PlayletApi";
import { searchHistoryStore } from "../Stores";
import { PlayletApi } from "lib/Api/PlayletApi";
import { searchHistoryStore } from "lib/Stores";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
@@ -19,7 +19,7 @@
<div class="m-5">
<div class={textSizes[level]}>{displayText}</div>
<div class="text-xs text-gray-500">{description}</div>
<div class="text-xs text-gray-500">{@html description}</div>
<button class="btn m-1" on:click={clearSeachHistory}
>Clear search history</button
>
@@ -1,6 +1,6 @@
<script lang="ts">
import { PlayletApi } from "../PlayletApi";
import { userPreferencesStore } from "../Stores";
import { PlayletApi } from "lib/Api/PlayletApi";
import { userPreferencesStore } from "lib/Stores";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
@@ -25,7 +25,7 @@
<div class="m-5">
<div class={textSizes[level]}>{displayText}</div>
<div class="text-xs text-gray-500">{description}</div>
<div class="text-xs text-gray-500">{@html description}</div>
{#each options as option}
<div class="form-control">
@@ -1,6 +1,6 @@
<script lang="ts">
import { PlayletApi } from "../PlayletApi";
import { userPreferencesStore } from "../Stores";
import { PlayletApi } from "lib/Api/PlayletApi";
import { userPreferencesStore } from "lib/Stores";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
@@ -27,7 +27,7 @@
<div class="m-5">
<div class={textSizes[level]}>{displayText}</div>
<div class="text-xs text-gray-500">{description}</div>
<div class="text-xs text-gray-500">{@html description}</div>
<div class="join w-full m-1">
<input
@@ -1,8 +1,8 @@
<script lang="ts">
import BooleanControl from "./SettingControls/BooleanControl.svelte";
import ClearSearchHistoryControl from "./SettingControls/ClearSearchHistoryControl.svelte";
import RadioControl from "./SettingControls/RadioControl.svelte";
import StringControl from "./SettingControls/StringControl.svelte";
import BooleanControl from "lib/Screens/Settings/SettingControls/BooleanControl.svelte";
import ClearSearchHistoryControl from "lib/Screens/Settings/SettingControls/ClearSearchHistoryControl.svelte";
import RadioControl from "lib/Screens/Settings/SettingControls/RadioControl.svelte";
import StringControl from "lib/Screens/Settings/SettingControls/StringControl.svelte";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
@@ -15,15 +15,15 @@
export let visibility: string | undefined = undefined;
export let children: any[] | undefined = [];
export let level: number = 0;
// svelte-ignore unused-export-let
export let defaultValue: any = undefined;
// svelte-ignore unused-export-let
export let rokuComponent: any = undefined;
const customComponents = {
ClearSearchHistoryControl
}
ClearSearchHistoryControl,
};
</script>
{#if visibility !== "tv"}
@@ -34,7 +34,13 @@
{:else if type === "string"}
<StringControl {displayText} {key} {description} {level} />
{:else if svelteComponent}
<svelte:component this={customComponents[svelteComponent]} {displayText} {key} {description} {level} />
<svelte:component
this={customComponents[svelteComponent]}
{displayText}
{key}
{description}
{level}
/>
{:else}
<div class="m-5">
<div class={textSizes[level]}>{displayText}</div>
@@ -0,0 +1,21 @@
<script lang="ts">
import DevSettings from "lib/Screens/Settings/DevSettings.svelte";
import SettingsNode from "lib/Screens/Settings/SettingsNode.svelte";
import { preferencesModelStore } from "lib/Stores";
import { onMount } from "svelte";
export let visibility: boolean;
</script>
<div class={visibility ? "" : "hidden"}>
{#each $preferencesModelStore as pref, i}
{#if pref.visibility !== "tv"}
<SettingsNode {...pref} />
{#if i !== $preferencesModelStore.length - 1}
<div class="divider" />
{/if}
{/if}
{/each}
<div class="divider" />
<DevSettings />
</div>
+23 -15
View File
@@ -1,31 +1,39 @@
<script lang="ts">
import { onMount } from "svelte";
import { appThemeStore } from "./Stores";
import { appThemeStore } from "lib/Stores";
let checked;
appThemeStore.subscribe((value) => {
checked = value === "dark";
document.documentElement.setAttribute("data-theme", value);
checked = value === "dark";
document.documentElement.setAttribute("data-theme", value);
});
onMount(() => {
const savedTheme = localStorage.getItem('theme') as 'dark' | 'light' | undefined;
if(savedTheme) {
appThemeStore.set(savedTheme);
}
const savedTheme = localStorage.getItem("theme") as
| "dark"
| "light"
| undefined;
if (savedTheme) {
appThemeStore.set(savedTheme);
}
});
function handleChange() {
const theme = checked ? "dark" : "light";
localStorage.setItem("theme", theme);
appThemeStore.set(theme);
const theme = checked ? "dark" : "light";
localStorage.setItem("theme", theme);
appThemeStore.set(theme);
}
</script>
<div class="flex flex-row m-3">
<div class="p-2">☀️</div>
<label class="flex items-center">
<input type="checkbox" class="toggle toggle-sm p2" bind:checked={checked} on:change={handleChange} />
</label>
<div class="p-2">🌙</div>
<div class="p-2">☀️</div>
<label class="flex items-center">
<input
type="checkbox"
class="toggle toggle-sm p2"
bind:checked
on:change={handleChange}
/>
</label>
<div class="p-2">🌙</div>
</div>