Add Svelte app boilerplate (#27)

* Add Svelte app boilerplate

* Delete www folder

* Web app setup

* Fix vector images

* README
This commit is contained in:
Brahim Hadriche authored and GitHub committed 2022-12-07 12:43:33 -05:00
1 parent f71c70d90b
commit 9031f51d5d
31 files changed
+3403 -68

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
+3
View File
@@ -0,0 +1,3 @@
{
"recommendations": ["svelte.svelte-vscode"]
}
+3
View File
@@ -0,0 +1,3 @@
# Playlet web
This is the Playlet companion web app, which allows the configuration and control of the playlet app.
+12
View File
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Playlet</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
+2849
View File
File diff suppressed because it is too large. Load diff
+23
View File
@@ -0,0 +1,23 @@
{
"name": "playlet-web",
"version": "0.5.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^1.1.0",
"@tsconfig/svelte": "^3.0.0",
"dotenv": "^16.0.3",
"internal-ip": "^7.0.0",
"svelte": "^3.52.0",
"svelte-check": "^2.9.2",
"svelte-preprocess": "^4.10.7",
"tslib": "^2.4.0",
"typescript": "^4.6.4",
"vite": "^3.2.3"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

+346
View File
@@ -0,0 +1,346 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Playlet</title>
<style>
table,
th,
td {
border: 1px solid;
cursor: all-scroll;
}
table {
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
</style>
</head>
<body ondrop="OnBodyDrop(event);" ondragover="OnBodyDragover(event);">
<h2>Playlet - Youtube Player for Roku</h2>
<h4 id="app-version">Version: </h4>
<h4>Invidious Instance: <a id="instance" target="_blank">None</a></h4>
<button onclick="PlayVideo()">Play Video</button>
<label for="video-id">Video ID:</label>
<input type="text" id="video-id" name="video-id" style="min-width:300px;">
<h4 id="logged-in">Logged In: </h4>
<button style="display: none" id="login-button" onclick="Login()">Login</button>
<button style="display: none" id="logout-button" onclick="Logout()">Logout</button>
<br />
<table id="instances">
<thead>
<tr>
<th>Instances - find more at <a href="https://api.invidious.io/" target="_blank">api.invidious.io</a></th>
</tr>
</thead>
<tbody>
</tbody>
<tbody>
<tr id="instance-input-row">
<td>
<input type="text" id="instance-input" name="new-instance" oninput="OnNewInstanceTextChanged()"
style="min-width:300px;">
</td>
<td>
<button id="instance-add" disabled="true" onclick="AddInstance()">Add</button>
</td>
</tr>
</tbody>
</table>
</br>
<button style="display: none" id="update-instances" onclick="UpdateInstances()">Update Instances</button>
</br>
<button onclick="ClearSearchHistory()">Clear Search History</button>
<h5>Instructions</h5>
<ul>
<li>Make sure you are logged in the Invidious instance before logging in on this page</li>
<li>If this is your first time using this invidious Instance, you might want to create an account</li>
<li>Once you are logged in to your current instance, click "Login" on this page, and authorize the token</li>
<li>Once logged in, this page should show "Logged In: true"</li>
<li>After login, the home page should refresh automatically. You should then be able to see your Subscription feed
and Playlists, if you have any.</li>
</ul>
<p>
This is a barebone page for now, stay tuned for a redesigned page!
</p>
<h5>Feedback is welcome over at: <a id="feedback-url" href="https://github.com/iBicha/playlet"
target="_blank">https://github.com/iBicha/playlet</a></h5>
<script>
function Login() {
if (!window.appState) {
alert("Error with login, please refresh the page.")
}
window.location = window.appState.invidious.auth_url
}
function Logout() {
PostJson('/api/command', { command: "logout" })
.then(function (response) {
window.location.reload();
})
.catch(function (err) {
alert(err)
});
}
function PlayVideo() {
let v = document.getElementById('video-id').value
if (IsValidHttpUrl(v)) {
v = GetVideoId(v)
}
if (!v || v.length < 8) {
alert("Please set video id")
return
}
PostJson('/api/command', { command: "play", videoId: v })
.catch(function (err) {
alert(err)
});
}
function ClearSearchHistory() {
PostJson('/api/command', { command: "clear-search-history" })
.then(function (response) {
alert("Search history cleared");
})
.catch(function (err) {
alert(err)
});
}
function CreateGithubIssueUrl() {
title = "[Feedback] Playlet"
body = `### Feedback
_insert feedback here_
#### App Info
\`\`\`
${JSON.stringify(window.appState.app, null, 2)}
\`\`\`
#### Device Info
\`\`\`
${JSON.stringify(window.appState.device, null, 2)}
\`\`\``;
return `https://github.com/iBicha/playlet/issues/new?title=${encodeURIComponent(title)}&body=${encodeURIComponent(body)}`
}
function IsValidHttpUrl(string) {
let url;
try {
url = new URL(string);
} catch (_) {
return false;
}
return url.protocol === "http:" || url.protocol === "https:";
}
function GetVideoId(url) {
// Share/Short url
const YoutubeUrls = [
"https://youtu.be/",
"http://youtu.be/",
"https://www.youtu.be/",
"http://www.youtu.be/",
"https://youtube.com/shorts/",
"http://youtube.com/shorts/",
"https://www.youtube.com/shorts/",
"http://www.youtube.com/shorts/",
]
for (var i in YoutubeUrls) {
let youtubeUrl = YoutubeUrls[i];
if (url.startsWith(youtubeUrl)) {
url = url.replace(youtubeUrl, "")
if (url.includes("?")) {
url = url.substring(0, url.indexOf("?"))
}
return url
}
}
// regular url
url = new URL(url)
const urlSearchParams = new URLSearchParams(url.search);
return urlSearchParams.get('v')
}
function OnNewInstanceTextChanged() {
document.getElementById("instance-add").disabled = !IsValidHttpUrl(document.getElementById("instance-input").value)
}
function AddInstance() {
instance = document.getElementById("instance-input").value
AddInstanceRow(instance)
document.getElementById("instance-input").value = ""
document.getElementById("update-instances").style.display = "block";
}
function AddInstanceRow(instance) {
instances = document.getElementById("instances").getElementsByTagName('tbody')[0];
var row = instances.insertRow();
row.draggable = true
row.addEventListener('dragstart', OnTableRowDragStart);
row.addEventListener('dragover', OnTableRowDragover);
row.addEventListener('drop', OnTableRowDrop);
var cell = row.insertCell();
style = instance === window.appState.invidious.selected_instance ? `style="font-weight:bold"` : ""
cell.innerHTML = `<a href="${instance}" ${style} target="_blank">${instance}</a>`
cell = row.insertCell();
cell.innerHTML = `<button onclick="RemoveInstance('${instance}')">Remove</button>`
}
function RemoveInstance(instance) {
instanceRows = Array.from(document.getElementById("instances")
.getElementsByTagName('tbody')[0]
.getElementsByTagName('tr'));
for (const i in instanceRows) {
currentInstance = instanceRows[i].getElementsByTagName('a')[0].innerText
if (currentInstance === instance) {
instanceRows[i].remove()
document.getElementById("update-instances").style.display = "block";
return;
}
}
}
function UpdateInstances() {
instances = Array.from(document.getElementById("instances")
.getElementsByTagName('tbody')[0]
.getElementsByTagName('td'))
.map(el => el.getElementsByTagName('a')[0])
.filter(a => !!a)
.map(a => a.innerText);
PostJson('/invidious/instances', instances)
.then(function (response) {
alert("Instances updated. Restart Playlet to reflect changes.")
window.location.reload();
})
.catch(function (err) {
alert(err)
});
}
function PostJson(url, payload) {
return fetch(url,
{
headers: {
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify(payload)
})
}
function Initialize() {
fetch("/api/state")
.then(function (response) {
return response.json();
})
.then(function (appState) {
window.appState = appState
console.log(appState)
document.getElementById("app-version").innerText = `Version: ${appState.app.version}`
if (appState.invidious.logged_in) {
document.getElementById("logged-in").innerHTML = `Logged In: true (<a href="${appState.invidious.logged_in_instance}" target="_blank">${appState.invidious.logged_in_instance}</a>)`
} else {
document.getElementById("logged-in").innerHTML = "Logged In: false"
}
instanceEl = document.getElementById("instance")
instanceEl.innerText = instanceEl.href = appState.invidious.selected_instance
for (var i in appState.invidious.instances) {
AddInstanceRow(appState.invidious.instances[i])
}
loginButton = document.getElementById("login-button")
loginButton.innerText = `Login (${appState.invidious.selected_instance})`
loginButton.style.display = appState.invidious.logged_in ? "none" : "block";
document.getElementById("logout-button").style.display = !appState.invidious.logged_in ? "none" : "block";
document.getElementById("feedback-url").href = CreateGithubIssueUrl()
})
.catch(function (err) {
alert(err)
});
}
var tableRow;
function OnTableRowDragStart(event) {
target = event.target;
while (target && target.tagName !== 'TR') {
target = target.parentNode
}
if (target.id === "instance-input-row") {
return
}
tableRow = target
}
function OnTableRowDragover(event) {
event.preventDefault();
if (!tableRow) {
return
}
target = event.target;
while (target && target.tagName !== 'TR') {
target = target.parentNode
}
if (!target || target.id === "instance-input-row") {
return
}
let children = Array.from(target.parentNode.children);
if (children.indexOf(target) > children.indexOf(tableRow))
target.after(tableRow);
else
target.before(tableRow);
}
function OnTableRowDrop(event) {
event.preventDefault();
tableRow = undefined
document.getElementById("update-instances").style.display = "block";
}
function OnBodyDrop(event) {
for (var i in event.dataTransfer.items) {
let item = event.dataTransfer.items[i]
if (item.kind = 'string' && item.getAsString) {
item.getAsString((dataString) => {
if (IsValidHttpUrl(dataString) && GetVideoId(dataString)) {
document.getElementById('video-id').value = dataString
}
});
}
}
event.preventDefault();
}
function OnBodyDragover(event) {
event.preventDefault();
}
Initialize();
</script>
</body>
</html>
+34
View File
@@ -0,0 +1,34 @@
<script lang="ts">
import playletLogo from "./assets/logo-dark.svg";
import Counter from "./lib/Counter.svelte";
import CurrentInstance from "./lib/CurrentInstance.svelte";
import { GetHost } from "./lib/Host";
</script>
<main>
<div>
<img src={playletLogo} class="logo" alt="Playlet Logo" />
</div>
<h1>Playlet</h1>
<div class="card">
<Counter />
</div>
<div class="card">
Host: {GetHost()}
</div>
<div class="card">
<CurrentInstance />
</div>
</main>
<style>
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
</style>
+81
View File
@@ -0,0 +1,81 @@
:root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
.card {
padding: 2em;
}
#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
+163
View File
@@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="1920"
height="745"
viewBox="0 0 508 197.11453"
version="1.1"
id="svg10011"
sodipodi:docname="logo-dark.svg"
inkscape:version="1.2.1 (9c6d41e4, 2022-07-14)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview34"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showgrid="false"
inkscape:zoom="0.21851852"
inkscape:cx="748.22034"
inkscape:cy="576.61017"
inkscape:window-width="1440"
inkscape:window-height="758"
inkscape:window-x="0"
inkscape:window-y="25"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs10008">
<rect
x="180.21565"
y="328.72668"
width="570.68286"
height="243.62486"
id="rect418-2-51" />
<rect
x="180.21565"
y="328.72668"
width="570.68286"
height="243.62486"
id="rect418-2-8-2" />
<rect
x="180.21565"
y="328.72668"
width="570.68286"
height="243.62486"
id="rect418-2-53-6" />
<rect
x="180.21565"
y="328.72668"
width="570.68286"
height="243.62486"
id="rect418-2-6-6" />
<rect
x="180.21565"
y="328.72668"
width="570.68286"
height="243.62486"
id="rect418-2-5-5" />
<rect
x="180.21565"
y="328.72668"
width="570.68286"
height="243.62486"
id="rect418-2-1-4" />
<rect
x="180.21565"
y="328.72668"
width="570.68286"
height="243.62486"
id="rect418-2-3-1" />
</defs>
<g
id="layer1"
transform="matrix(1.7349039,0,0,1.7349039,-186.21265,-148.69195)">
<rect
style="fill:#f0f9f2;fill-opacity:1;stroke:none;stroke-width:3.68071;stroke-linejoin:round;stroke-dasharray:none"
id="rect8445-7"
width="192.9267"
height="108.94424"
x="109.70631"
y="88.402878"
rx="20.13974"
ry="19.408449" />
<g
aria-label="P"
transform="matrix(1.3208994,0,0,1.3208994,-115.36013,-354.38654)"
id="text416-2-13"
style="font-size:74.6667px;font-family:'The Amaranth';-inkscape-font-specification:'The Amaranth, Normal';white-space:pre;shape-inside:url(#rect418-2-51);display:inline;fill:#ff1c30;stroke-width:1.06591;stroke-linejoin:round">
<path
d="m 182.08151,397.45387 v -50.02669 h 15.38134 q 4.032,0 7.54134,1.49333 3.50933,1.49334 6.12267,4.18134 2.61333,2.61333 4.10667,6.12267 1.49333,3.50933 1.49333,7.54133 0,3.95734 -1.49333,7.46667 -1.49334,3.50934 -4.10667,6.12267 -2.61334,2.53867 -6.12267,4.03201 -3.50934,1.49333 -7.54134,1.49333 h -8.81067 v 11.57334 z m 6.57067,-18.14401 h 8.81067 q 2.61334,0 4.928,-0.97067 2.31467,-1.04533 4.03201,-2.688 1.71733,-1.71733 2.688,-3.95733 1.04533,-2.31467 1.04533,-4.92801 0,-2.688 -1.04533,-5.00267 -0.97067,-2.31466 -2.688,-4.032 -1.71734,-1.71733 -4.03201,-2.688 -2.31466,-0.97067 -4.928,-0.97067 h -8.81067 z"
style="font-family:'Bunya PERSONAL';-inkscape-font-specification:'Bunya PERSONAL, Normal'"
id="path335" />
</g>
<g
aria-label="l"
transform="matrix(1.3208994,0,0,1.3208994,-65.866935,-354.45042)"
id="text416-2-1-4"
style="font-size:74.6667px;font-family:'The Amaranth';-inkscape-font-specification:'The Amaranth, Normal';white-space:pre;shape-inside:url(#rect418-2-8-2);display:inline;fill:#ff1c30;stroke-width:1.06591;stroke-linejoin:round">
<path
d="m 189.92152,349.36851 v 48.08536 h -6.27201 v -48.08536 z"
style="font-family:'Bunya PERSONAL';-inkscape-font-specification:'Bunya PERSONAL, Normal'"
id="path332" />
</g>
<g
aria-label="e"
transform="matrix(1.3208994,0,0,1.3208994,87.108046,-354.30193)"
id="text416-2-5-8"
style="font-size:74.6667px;font-family:'The Amaranth';-inkscape-font-specification:'The Amaranth, Normal';white-space:pre;shape-inside:url(#rect418-2-53-6);display:inline;fill:#ff1c30;stroke-width:1.06591;stroke-linejoin:round">
<path
d="m 216.35353,388.8672 q -3.06134,4.55467 -7.24267,6.64533 -4.10667,2.09067 -8.96001,2.09067 -3.808,0 -7.168,-1.41867 -3.36,-1.49333 -5.824,-3.95733 -2.464,-2.464 -3.95734,-5.824 -1.41867,-3.36001 -1.41867,-7.16801 0,-3.88267 1.41867,-7.24267 1.49334,-3.36 3.95734,-5.824 2.464,-2.53867 5.824,-3.95734 3.36,-1.49333 7.168,-1.49333 4.85334,0 9.10934,2.24 4.33067,2.24 7.46667,6.944 l -21.65334,20.16001 q 1.19466,0.82134 2.98667,1.19467 1.792,0.29867 3.584,0.0747 3.136,-0.37334 5.824,-2.09067 2.76267,-1.792 4.62934,-4.48 z m -28.59735,-10.60267 q -0.224,2.83733 0.74667,5.22666 0.97066,2.38934 2.76267,3.73334 l 17.09867,-16.65067 q -1.41867,-1.71734 -3.808,-2.76267 -2.38934,-1.12 -5.22667,-0.97067 -2.31467,0.14933 -4.33067,1.04533 -2.016,0.896 -3.584,2.46401 -1.49333,1.49333 -2.464,3.50933 -0.97067,2.016 -1.19467,4.40534 z"
style="font-family:'Bunya PERSONAL';-inkscape-font-specification:'Bunya PERSONAL, Normal'"
id="path329" />
</g>
<g
aria-label="t"
transform="matrix(1.3208994,0,0,1.3208994,138.55003,-354.31168)"
id="text416-2-59-6"
style="font-size:74.6667px;font-family:'The Amaranth';-inkscape-font-specification:'The Amaranth, Normal';white-space:pre;shape-inside:url(#rect418-2-6-6);display:inline;fill:#ff1c30;stroke-width:1.06591;stroke-linejoin:round">
<path
d="m 180.21484,360.71785 h 3.43467 v -11.34934 h 6.34667 v 11.34934 h 6.64534 v 5.22667 h -6.64534 v 20.23468 q 0,2.61333 1.64267,4.256 1.64267,1.568 4.256,1.568 v 5.6 q -6.048,0 -9.184,-2.912 -3.06134,-2.912 -3.06134,-8.512 v -20.23468 h -3.43467 z"
style="font-family:'Bunya PERSONAL';-inkscape-font-specification:'Bunya PERSONAL, Normal'"
id="path317" />
</g>
<g
aria-label="l"
transform="matrix(1.3208994,0,0,1.3208994,69.600141,-354.30583)"
id="text416-2-8-1"
style="font-size:74.6667px;font-family:'The Amaranth';-inkscape-font-specification:'The Amaranth, Normal';white-space:pre;shape-inside:url(#rect418-2-5-5);display:inline;fill:#ff1c30;stroke-width:1.06591;stroke-linejoin:round">
<path
d="m 189.92152,349.36851 v 48.08536 h -6.27201 v -48.08536 z"
style="font-family:'Bunya PERSONAL';-inkscape-font-specification:'Bunya PERSONAL, Normal'"
id="path326" />
</g>
<g
aria-label="a"
transform="matrix(1.3208994,0,0,1.3208994,-48.469095,-354.51494)"
id="text416-2-4-5"
style="font-size:74.6667px;font-family:'The Amaranth';-inkscape-font-specification:'The Amaranth, Normal';white-space:pre;shape-inside:url(#rect418-2-1-4);display:inline;fill:#ff1c30;stroke-width:1.06591;stroke-linejoin:round">
<path
d="m 181.85751,379.23519 q 0,-3.88267 1.344,-7.24267 1.344,-3.36 3.584,-5.824 2.31467,-2.53867 5.37601,-3.95734 3.136,-1.49333 6.72,-1.49333 4.256,0 7.76534,2.09067 3.50933,2.016 5.74933,5.45067 v -7.39201 h 6.34667 v 36.58669 h -6.34667 v -7.31734 q -2.24,3.43467 -5.74933,5.45067 -3.50934,2.016 -7.76534,2.016 -3.584,0 -6.72,-1.41867 -3.06134,-1.49333 -5.37601,-3.95733 -2.24,-2.464 -3.584,-5.824 -1.344,-3.36001 -1.344,-7.16801 z m 6.34667,0 q 0,2.464 0.896,4.704 0.97067,2.16534 2.53867,3.80801 1.64267,1.64266 3.808,2.61333 2.24,0.896 4.77867,0.896 2.464,0 4.62934,-0.896 2.24,-0.97067 3.88266,-2.61333 1.64267,-1.64267 2.61334,-3.80801 0.97067,-2.24 0.97067,-4.704 0,-2.464 -0.97067,-4.704 -0.97067,-2.24 -2.61334,-3.88267 -1.64266,-1.64267 -3.88266,-2.61333 -2.16534,-0.97067 -4.62934,-0.97067 -2.53867,0 -4.77867,0.97067 -2.16533,0.97066 -3.808,2.61333 -1.568,1.64267 -2.53867,3.88267 -0.896,2.24 -0.896,4.704 z"
style="font-family:'Bunya PERSONAL';-inkscape-font-specification:'Bunya PERSONAL, Normal'"
id="path323" />
</g>
<g
aria-label="y"
transform="matrix(1.3208994,0,0,1.3208994,9.0695965,-354.11012)"
id="text416-2-84-0"
style="font-size:74.6667px;font-family:'The Amaranth';-inkscape-font-specification:'The Amaranth, Normal';white-space:pre;shape-inside:url(#rect418-2-3-1);display:inline;fill:#ff1c30;stroke-width:1.06591;stroke-linejoin:round">
<path
d="m 186.56151,360.86718 10.97601,28.07468 10.752,-28.07468 h 6.72001 l -18.74135,47.56269 h -6.272 l 4.256,-10.82667 -14.48534,-36.73602 z"
style="font-family:'Bunya PERSONAL';-inkscape-font-specification:'Bunya PERSONAL, Normal'"
id="path320" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 8.7 KiB

+10
View File
@@ -0,0 +1,10 @@
<script lang="ts">
let count: number = 0
const increment = () => {
count += 1
}
</script>
<button on:click={increment}>
count is {count}
</button>
@@ -0,0 +1,16 @@
<script lang="ts">
import { onMount } from "svelte";
import { GetHost } from "./Host";
let currentInstance = "N/A";
onMount(async () => {
const response = await fetch(`http://${GetHost()}/api/state`);
const state = await response.json();
currentInstance = state.invidious.selected_instance;
})
</script>
<div>
Current Instance: {currentInstance}
</div>
+6
View File
@@ -0,0 +1,6 @@
function GetHost() {
const urlSearchParams = new URLSearchParams(window.location.search);
return urlSearchParams.get('host') ?? window.location.host
}
export { GetHost }
+8
View File
@@ -0,0 +1,8 @@
import './app.css'
import App from './App.svelte'
const app = new App({
target: document.getElementById('app')
})
export default app
+2
View File
@@ -0,0 +1,2 @@
/// <reference types="svelte" />
/// <reference types="vite/client" />
+7
View File
@@ -0,0 +1,7 @@
import sveltePreprocess from 'svelte-preprocess'
export default {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: sveltePreprocess()
}
+20
View File
@@ -0,0 +1,20 @@
{
"extends": "@tsconfig/svelte/tsconfig.json",
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"resolveJsonModule": true,
/**
* Typecheck JS in `.svelte` and `.js` files by default.
* Disable checkJs if you'd like to use dynamic types in JS.
* Note that setting allowJs false does not prevent the use
* of JS in `.svelte` files.
*/
"allowJs": true,
"checkJs": true,
"isolatedModules": true
},
"include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
"references": [{ "path": "./tsconfig.node.json" }]
}
+8
View File
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node"
},
"include": ["vite.config.ts"]
}
+24
View File
@@ -0,0 +1,24 @@
import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import { readFileSync } from 'fs'
import { parse as dotEnvParse } from 'dotenv'
import { internalIpV4Sync } from 'internal-ip';
const envVars = dotEnvParse(readFileSync('../.vscode/.env'))
const PORT = 5173
// https://vitejs.dev/config/
/** @type {import('vite').UserConfig} */
export default defineConfig({
plugins: [svelte()],
build: {
outDir: "../src/www",
emptyOutDir: true
},
server: {
host: true,
port: PORT,
open: `http://${internalIpV4Sync()}:${PORT}/?host=${envVars.ROKU_DEV_TARGET}:8888`
}
})