⬆️ Upgraded SvelteKit

This commit is contained in:
Mawoka
2022-08-18 15:35:01 +02:00
parent 12ec2ebf94
commit 9b79358db3
31 changed files with 198 additions and 324 deletions
@@ -4,14 +4,18 @@
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module"> <script context="module">
/** @type {import('@sveltejs/kit').Load} */ export function load({ error, status }) { throw new Error(
return { '@migration task: Replace error load function (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3293209)'
props: { );
status,
message: error.message // /** @type {import('@sveltejs/kit').Load} */ export function load({ error, status }) {
} // return {
}; // props: {
} // status,
// message: error.message
// }
// };
// }
</script> </script>
<script lang="ts"> <script lang="ts">
@@ -4,14 +4,18 @@
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module" lang="ts"> <script context="module" lang="ts">
import { signedIn } from '$lib/stores'; throw new Error(
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
);
export async function load({ session }) { // import { signedIn } from '$lib/stores';
if (session.authenticated) {
signedIn.set(true); // export async function load({ session }) {
} // if (session.authenticated) {
return {}; // signedIn.set(true);
} // }
// return {};
// }
</script> </script>
<script> <script>
@@ -4,18 +4,22 @@
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script lang="ts" context="module"> <script lang="ts" context="module">
import { signedIn } from '$lib/stores'; throw new Error(
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
);
export async function load({ session }) { // import { signedIn } from '$lib/stores';
if (session.authenticated) {
signedIn.set(true); // export async function load({ session }) {
return { // if (session.authenticated) {
status: 302, // signedIn.set(true);
redirect: '/dashboard' // return {
}; // status: 302,
} // redirect: '/dashboard'
return {}; // };
} // }
// return {};
// }
</script> </script>
<script lang="ts"> <script lang="ts">
@@ -4,14 +4,18 @@
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script lang="ts" context="module"> <script lang="ts" context="module">
import { signedIn } from '$lib/stores'; throw new Error(
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
);
export async function load({ session }) { // import { signedIn } from '$lib/stores';
if (session.authenticated) {
signedIn.set(true); // export async function load({ session }) {
} // if (session.authenticated) {
return {}; // signedIn.set(true);
} // }
// return {};
// }
</script> </script>
<script lang="ts"> <script lang="ts">
@@ -3,29 +3,11 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module" lang="ts">
export async function load({ session, url }) {
const verified = url.searchParams.get('verified');
const returnTo =
url.searchParams.get('returnTo') !== null
? url.searchParams.get('returnTo')
: '/dashboard';
if (session.authenticated) {
return {
status: 302,
redirect: returnTo
};
}
return {
status: 200,
props: {
verified: verified !== null
}
};
}
</script>
<script lang="ts"> <script lang="ts">
throw new Error(
'@migration task: Add data prop (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292707)'
);
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { navbarVisible } from '$lib/stores'; import { navbarVisible } from '$lib/stores';
import { browser } from '$app/env'; import { browser } from '$app/env';
@@ -3,18 +3,11 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script lang="ts" context="module">
export async function load({ url }) {
const error = url.searchParams.get('error');
return {
props: {
error
}
};
}
</script>
<script lang="ts"> <script lang="ts">
throw new Error(
'@migration task: Add data prop (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292707)'
);
export let error: string; export let error: string;
</script> </script>
@@ -3,20 +3,12 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script lang="ts" context="module">
export async function load({ url }) {
const token = url.searchParams.get('token');
return {
props: {
token
}
};
}
</script>
<script lang="ts"> <script lang="ts">
import { getLocalization } from '../../lib/i18n'; throw new Error(
'@migration task: Add data prop (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292707)'
);
import { getLocalization } from '../../../lib/i18n';
const { t } = getLocalization(); const { t } = getLocalization();
export let token: string; export let token: string;
@@ -3,18 +3,6 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module" lang="ts">
export async function load({ session }) {
if (session.authenticated) {
return {
status: 302,
redirect: '/dashboard'
};
}
return {};
}
</script>
<script lang="ts"> <script lang="ts">
import { createForm } from 'felte'; import { createForm } from 'felte';
import { getLocalization } from '$lib/i18n'; import { getLocalization } from '$lib/i18n';
@@ -3,18 +3,6 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module" lang="ts">
export async function load({ session }) {
if (session.authenticated) {
return {
status: 302,
redirect: '/dashboard'
};
}
return {};
}
</script>
<script lang="ts"> <script lang="ts">
import { getLocalization } from '$lib/i18n'; import { getLocalization } from '$lib/i18n';
import { navbarVisible } from '$lib/stores'; import { navbarVisible } from '$lib/stores';
@@ -3,22 +3,6 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module" lang="ts">
export async function load({ session }) {
if (!session.authenticated) {
return {
status: 302,
redirect: '/account/login?returnTo=/account/settings'
};
}
return {
props: {
email: session.email
}
};
}
</script>
<script lang="ts"> <script lang="ts">
import { getLocalization } from '$lib/i18n'; import { getLocalization } from '$lib/i18n';
import { DateTime } from 'luxon'; import { DateTime } from 'luxon';
@@ -3,31 +3,11 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module" lang="ts">
export async function load({ session, url }) {
if (!session.authenticated) {
return {
status: 302,
redirect: '/account/login'
};
}
const token = url.searchParams.get('token');
const pin = url.searchParams.get('pin');
let auto_connect = url.searchParams.get('connect') !== null;
if (token === null || pin === null) {
auto_connect = false;
}
return {
props: {
game_pin: pin === null ? '' : pin,
game_token: token === null ? '' : token,
auto_connect: auto_connect
}
};
}
</script>
<script lang="ts"> <script lang="ts">
throw new Error(
'@migration task: Add data prop (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292707)'
);
import type { QuizData } from '$lib/quiz_types'; import type { QuizData } from '$lib/quiz_types';
import { socket } from '$lib/socket'; import { socket } from '$lib/socket';
@@ -4,20 +4,24 @@
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module" lang="ts"> <script context="module" lang="ts">
import { signedIn } from '$lib/stores'; throw new Error(
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
);
export async function load({ session }) { // import { signedIn } from '$lib/stores';
if (!session.authenticated) {
return { // export async function load({ session }) {
status: 302, // if (!session.authenticated) {
redirect: '/account/login?returnTo=/create' // return {
}; // status: 302,
} // redirect: '/account/login?returnTo=/create'
if (session.authenticated) { // };
signedIn.set(true); // }
} // if (session.authenticated) {
return {}; // signedIn.set(true);
} // }
// return {};
// }
</script> </script>
<script lang="ts"> <script lang="ts">
@@ -3,22 +3,6 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module" lang="ts">
export async function load({ session }) {
if (!session.authenticated) {
return {
status: 302,
redirect: '/account/login?returnTo=/dashboard'
};
}
return {
props: {
email: session.email
}
};
}
</script>
<script lang="ts"> <script lang="ts">
import type { Question } from '$lib/quiz_types'; import type { Question } from '$lib/quiz_types';
import { DateTime } from 'luxon'; import { DateTime } from 'luxon';
@@ -4,14 +4,18 @@
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script lang="ts" context="module"> <script lang="ts" context="module">
import { signedIn } from '$lib/stores'; throw new Error(
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
);
export async function load({ session }) { // import { signedIn } from '$lib/stores';
if (session.authenticated) {
signedIn.set(true); // export async function load({ session }) {
} // if (session.authenticated) {
return {}; // signedIn.set(true);
} // }
// return {};
// }
</script> </script>
<script lang="ts"> <script lang="ts">
@@ -3,10 +3,6 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module">
export const prerender = true;
</script>
<svelte:head> <svelte:head>
<title>ClassQuiz/docs - Index</title> <title>ClassQuiz/docs - Index</title>
<meta <meta
@@ -3,10 +3,6 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module">
export const prerender = true;
</script>
<svelte:head> <svelte:head>
<title>ClassQuiz/docs - Attribution</title> <title>ClassQuiz/docs - Attribution</title>
<meta name="description" content="People who helped make with ClassQuiz." /> <meta name="description" content="People who helped make with ClassQuiz." />
@@ -3,10 +3,6 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module">
export const prerender = true;
</script>
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import '$lib/hljs.css'; import '$lib/hljs.css';
@@ -3,10 +3,6 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module">
export const prerender = true;
</script>
<svelte:head> <svelte:head>
<title>ClassQuiz/docs - Import from Kahoot</title> <title>ClassQuiz/docs - Import from Kahoot</title>
<meta <meta
@@ -3,10 +3,6 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module">
export const prerender = true;
</script>
<svelte:head> <svelte:head>
<title>ClassQuiz/docs - PoW</title> <title>ClassQuiz/docs - PoW</title>
<meta <meta
@@ -3,10 +3,6 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module">
export const prerender = true;
</script>
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import '$lib/hljs.css'; import '$lib/hljs.css';
@@ -3,10 +3,6 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module">
export const prerender = true;
</script>
<svelte:head> <svelte:head>
<title>ClassQuiz/docs - Roadmap</title> <title>ClassQuiz/docs - Roadmap</title>
<meta <meta
@@ -3,10 +3,6 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module">
export const prerender = true;
</script>
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import '$lib/hljs.css'; import '$lib/hljs.css';
@@ -7,10 +7,6 @@
hljs.highlightAll(); hljs.highlightAll();
}); });
</script>--> </script>-->
<script context="module">
export const prerender = true;
</script>
<!-- <!--
- This Source Code Form is subject to the terms of the Mozilla Public - This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -4,39 +4,47 @@
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script lang="ts" context="module"> <script lang="ts" context="module">
import { signedIn } from '$lib/stores'; throw new Error(
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
);
export async function load({ url, session }) { // import { signedIn } from '$lib/stores';
const quiz_id = url.searchParams.get('quiz_id');
if (!session.authenticated) {
return {
status: 302,
redirect: `/account/login?returnTo=/edit?quiz_id=${quiz_id}`
};
}
if (session.authenticated) { // export async function load({ url, session }) {
signedIn.set(true); // const quiz_id = url.searchParams.get('quiz_id');
} // if (!session.authenticated) {
// return {
// status: 302,
// redirect: `/account/login?returnTo=/edit?quiz_id=${quiz_id}`
// };
// }
if (quiz_id === null) { // if (session.authenticated) {
return { // signedIn.set(true);
status: 404 // }
};
} // if (quiz_id === null) {
return { // return {
props: { // status: 404
quiz_id // };
} // }
}; // return {
} // props: {
// quiz_id
// }
// };
// }
</script> </script>
<script lang="ts"> <script lang="ts">
throw new Error(
'@migration task: Add data prop (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292707)'
);
import Editor from '$lib/editor.svelte'; import Editor from '$lib/editor.svelte';
import { getLocalization } from '$lib/i18n'; import { getLocalization } from '$lib/i18n';
import { navbarVisible } from '$lib/stores'; import { navbarVisible } from '$lib/stores';
import { QuizQuestionType } from '../lib/quiz_types'; import { QuizQuestionType } from '../../lib/quiz_types';
navbarVisible.set(false); navbarVisible.set(false);
@@ -4,14 +4,18 @@
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module" lang="ts"> <script context="module" lang="ts">
import { signedIn } from '$lib/stores'; throw new Error(
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
);
export async function load({ session }) { // import { signedIn } from '$lib/stores';
if (session.authenticated) {
signedIn.set(true); // export async function load({ session }) {
} // if (session.authenticated) {
return {}; // signedIn.set(true);
} // }
// return {};
// }
</script> </script>
<script lang="ts"> <script lang="ts">
@@ -4,24 +4,28 @@
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module" lang="ts"> <script context="module" lang="ts">
import { signedIn } from '$lib/stores'; throw new Error(
export async function load({ session }) { '@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
if (!session.authenticated) { );
return {
status: 302, // import { signedIn } from '$lib/stores';
redirect: '/account/login?returnTo=/import' // export async function load({ session }) {
}; // if (!session.authenticated) {
} else { // return {
if (session.authenticated) { // status: 302,
signedIn.set(true); // redirect: '/account/login?returnTo=/import'
} // };
} // } else {
return { // if (session.authenticated) {
props: { // signedIn.set(true);
email: session.email // }
} // }
}; // return {
} // props: {
// email: session.email
// }
// };
// }
</script> </script>
<script lang="ts"> <script lang="ts">
@@ -7,10 +7,10 @@
import type { RequestHandler } from '@sveltejs/kit'; import type { RequestHandler } from '@sveltejs/kit';
export const GET: RequestHandler = async () => { export const GET: RequestHandler = async () => {
return { return new Response(undefined, {
status: 301, status: 301,
headers: { headers: {
Location: '/dashboard' Location: '/dashboard'
} }
}; });
}; };
@@ -4,22 +4,30 @@
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module" lang="ts"> <script context="module" lang="ts">
import { signedIn } from '$lib/stores'; throw new Error(
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
);
export async function load({ url, session }) { // import { signedIn } from '$lib/stores';
if (session.authenticated) {
signedIn.set(true); // export async function load({ url, session }) {
} // if (session.authenticated) {
const token = url.searchParams.get('pin'); // signedIn.set(true);
return { // }
props: { // const token = url.searchParams.get('pin');
game_pin: token === null ? '' : token // return {
} // props: {
}; // game_pin: token === null ? '' : token
} // }
// };
// }
</script> </script>
<script lang="ts"> <script lang="ts">
throw new Error(
'@migration task: Add data prop (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292707)'
);
import { socket } from '$lib/socket'; import { socket } from '$lib/socket';
import JoinGame from '$lib/play/join.svelte'; import JoinGame from '$lib/play/join.svelte';
import type { Answer, QuizData } from '$lib/quiz_types'; import type { Answer, QuizData } from '$lib/quiz_types';
@@ -4,14 +4,18 @@
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module" lang="ts"> <script context="module" lang="ts">
import { signedIn } from '$lib/stores'; throw new Error(
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
);
export async function load({ session }) { // import { signedIn } from '$lib/stores';
if (session.authenticated) {
signedIn.set(true); // export async function load({ session }) {
} // if (session.authenticated) {
return {}; // signedIn.set(true);
} // }
// return {};
// }
</script> </script>
<script lang="ts"> <script lang="ts">
@@ -3,22 +3,11 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script context="module">
/** @type {import('@sveltejs/kit').Load} */ export function load({ error, status }) {
return {
props: {
status,
message: error.message
}
};
}
</script>
<script lang="ts"> <script lang="ts">
import { navbarVisible } from '$lib/stores'; import { navbarVisible } from '$lib/stores';
import { page } from '$app/stores';
navbarVisible.set(true); navbarVisible.set(true);
export let status: number; let status = $page.status;
export let message: string;
</script> </script>
<svelte:head> <svelte:head>
@@ -3,33 +3,11 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. - file, You can obtain one at https://mozilla.org/MPL/2.0/.
--> -->
<script lang="ts" context="module">
import type { Load } from '@sveltejs/kit';
export const load: Load = async ({ params, fetch, session }) => {
const { quiz_id } = params;
const res = await fetch(`/api/v1/quiz/get/public/${quiz_id}`);
if (res.status === 404 || res.status === 400) {
return {
status: 404
};
} else if (res.status === 200) {
const quiz = await res.json();
return {
props: {
quiz: quiz,
logged_in: session.authenticated
}
};
} else {
return {
status: 500
};
}
};
</script>
<script lang="ts"> <script lang="ts">
throw new Error(
'@migration task: Add data prop (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292707)'
);
import { getLocalization } from '$lib/i18n'; import { getLocalization } from '$lib/i18n';
import CollapsSection from '$lib/collapsible.svelte'; import CollapsSection from '$lib/collapsible.svelte';
import { createTippy } from 'svelte-tippy'; import { createTippy } from 'svelte-tippy';