⬆️ Finished upgrading SvelteKit
This commit is contained in:
Vendored
-4
@@ -14,10 +14,6 @@ declare namespace App {
|
||||
}
|
||||
|
||||
// interface Platform {}
|
||||
interface Session {
|
||||
authenticated: boolean;
|
||||
email: string | null;
|
||||
}
|
||||
|
||||
// interface Stuff {}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import * as cookie from 'cookie';
|
||||
import type { Handle, GetSession } from '@sveltejs/kit';
|
||||
import type { Handle } from '@sveltejs/kit';
|
||||
|
||||
/** @type {import('@sveltejs/kit').Handle} */
|
||||
export const handle: Handle = async ({ event, resolve }) => {
|
||||
@@ -54,9 +54,9 @@ export const handle: Handle = async ({ event, resolve }) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const getSession: GetSession = async (event) => {
|
||||
/*export const getSession: GetSession = async (event) => {
|
||||
return {
|
||||
email: event.locals.email,
|
||||
authenticated: Boolean(event.locals.email)
|
||||
};
|
||||
};
|
||||
};*/
|
||||
|
||||
@@ -3,26 +3,12 @@
|
||||
- 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/.
|
||||
-->
|
||||
<script context="module">
|
||||
throw new Error(
|
||||
'@migration task: Replace error load function (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3293209)'
|
||||
);
|
||||
|
||||
// /** @type {import('@sveltejs/kit').Load} */ export function load({ error, status }) {
|
||||
// return {
|
||||
// props: {
|
||||
// status,
|
||||
// message: error.message
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { navbarVisible } from '$lib/stores';
|
||||
import { page } from '$app/stores';
|
||||
|
||||
navbarVisible.set(true);
|
||||
export let status: number;
|
||||
export let message: string;
|
||||
let status = $page.status;
|
||||
</script>
|
||||
|
||||
<!--
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { signedIn } from '$lib/stores';
|
||||
import type { LayoutLoad } from './$types';
|
||||
|
||||
export const load: LayoutLoad = async ({ locals }) => {
|
||||
if (locals.email) {
|
||||
signedIn.set(true);
|
||||
} else {
|
||||
signedIn.set(false);
|
||||
}
|
||||
return {
|
||||
email: locals.email
|
||||
};
|
||||
};
|
||||
@@ -3,21 +3,6 @@
|
||||
- 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/.
|
||||
-->
|
||||
<script context="module" lang="ts">
|
||||
throw new Error(
|
||||
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
|
||||
);
|
||||
|
||||
// import { signedIn } from '$lib/stores';
|
||||
|
||||
// export async function load({ session }) {
|
||||
// if (session.authenticated) {
|
||||
// signedIn.set(true);
|
||||
// }
|
||||
// return {};
|
||||
// }
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import '../app.css';
|
||||
import Navbar from '$lib/navbar.svelte';
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
// import { redirect } from '@sveltejs/kit';
|
||||
import { signedIn } from '$lib/stores';
|
||||
import type { LayoutLoad } from './$types';
|
||||
|
||||
export async function load({ session }) {
|
||||
if (session.authenticated) {
|
||||
export const load: LayoutLoad = async ({ data }) => {
|
||||
const { email } = data;
|
||||
if (email) {
|
||||
signedIn.set(true);
|
||||
// throw redirect(302, '/dashboard');
|
||||
} else {
|
||||
signedIn.set(false);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
// import { redirect } from '@sveltejs/kit';
|
||||
import { signedIn } from '$lib/stores';
|
||||
|
||||
export async function load({ session }) {
|
||||
if (session.authenticated) {
|
||||
signedIn.set(true);
|
||||
// throw redirect(302, '/dashboard');
|
||||
} else {
|
||||
signedIn.set(false);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -3,21 +3,6 @@
|
||||
- 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/.
|
||||
-->
|
||||
<script lang="ts" context="module">
|
||||
throw new Error(
|
||||
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
|
||||
);
|
||||
|
||||
// import { signedIn } from '$lib/stores';
|
||||
|
||||
// export async function load({ session }) {
|
||||
// if (session.authenticated) {
|
||||
// signedIn.set(true);
|
||||
// }
|
||||
// return {};
|
||||
// }
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { navbarVisible } from '$lib/stores';
|
||||
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
- file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
-->
|
||||
<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 { navbarVisible } from '$lib/stores';
|
||||
import { browser } from '$app/env';
|
||||
@@ -20,7 +16,8 @@
|
||||
|
||||
navbarVisible.set(true);
|
||||
|
||||
export let verified: boolean;
|
||||
export let data;
|
||||
const { verified }: boolean = data;
|
||||
|
||||
let loginData = {
|
||||
email: '',
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
|
||||
export async function load({ session, url }) {
|
||||
export async function load({ parent, url }) {
|
||||
const verified = url.searchParams.get('verified');
|
||||
const returnTo =
|
||||
url.searchParams.get('returnTo') !== null ? url.searchParams.get('returnTo') : '/dashboard';
|
||||
if (session.authenticated) {
|
||||
|
||||
const { email } = await parent();
|
||||
if (email) {
|
||||
throw redirect(302, returnTo);
|
||||
}
|
||||
return {
|
||||
|
||||
@@ -4,11 +4,8 @@
|
||||
- file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
-->
|
||||
<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 data;
|
||||
const { error } = data;
|
||||
</script>
|
||||
|
||||
<div>
|
||||
|
||||
@@ -4,14 +4,11 @@
|
||||
- file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
-->
|
||||
<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';
|
||||
|
||||
const { t } = getLocalization();
|
||||
export let token: string;
|
||||
export let data;
|
||||
let { token }: string = data;
|
||||
let isSubmitting = false;
|
||||
interface PasswordData {
|
||||
password1: string;
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
- file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
-->
|
||||
<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 { socket } from '$lib/socket';
|
||||
@@ -24,9 +20,8 @@
|
||||
// game_id: 'a7ddb6af-79ab-45e0-b996-6254c1ad9818',
|
||||
// game_pin: '66190765'
|
||||
// };
|
||||
export let game_pin: string;
|
||||
export let auto_connect: boolean;
|
||||
export let game_token: string;
|
||||
export let data;
|
||||
let { game_pin, auto_connect, game_token } = data;
|
||||
|
||||
let players: Array<Player> = [];
|
||||
let errorMessage = '';
|
||||
@@ -53,25 +48,25 @@
|
||||
console.log(quiz_data);
|
||||
success = true;
|
||||
});
|
||||
socket.on('player_joined', (data) => {
|
||||
players = [...players, data];
|
||||
socket.on('player_joined', (int_data) => {
|
||||
players = [...players, int_data];
|
||||
});
|
||||
socket.on('already_registered_as_admin', () => {
|
||||
errorMessage = $t('admin_page.already_registered_as_admin');
|
||||
});
|
||||
|
||||
socket.on('question_results', (data) => {
|
||||
socket.on('question_results', (int_data) => {
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
int_data = JSON.parse(int_data);
|
||||
} catch (e) {
|
||||
console.error('Failed to parse question results');
|
||||
return;
|
||||
}
|
||||
question_results = data;
|
||||
question_results = int_data;
|
||||
});
|
||||
socket.on('export_token', (data) => {
|
||||
socket.on('export_token', (int_data) => {
|
||||
warnToLeave = false;
|
||||
dataexport_download_a.href = `/api/v1/quiz/export_data/${data}?ts=${new Date().getTime()}&game_pin=${game_pin}`;
|
||||
dataexport_download_a.href = `/api/v1/quiz/export_data/${int_data}?ts=${new Date().getTime()}&game_pin=${game_pin}`;
|
||||
dataexport_download_a.click();
|
||||
warnToLeave = true;
|
||||
});
|
||||
|
||||
@@ -3,27 +3,6 @@
|
||||
- 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/.
|
||||
-->
|
||||
<script context="module" lang="ts">
|
||||
throw new Error(
|
||||
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
|
||||
);
|
||||
|
||||
// import { signedIn } from '$lib/stores';
|
||||
|
||||
// export async function load({ session }) {
|
||||
// if (!session.authenticated) {
|
||||
// return {
|
||||
// status: 302,
|
||||
// redirect: '/account/login?returnTo=/create'
|
||||
// };
|
||||
// }
|
||||
// if (session.authenticated) {
|
||||
// signedIn.set(true);
|
||||
// }
|
||||
// return {};
|
||||
// }
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import Editor from '$lib/editor.svelte';
|
||||
|
||||
@@ -3,21 +3,6 @@
|
||||
- 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/.
|
||||
-->
|
||||
<script lang="ts" context="module">
|
||||
throw new Error(
|
||||
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
|
||||
);
|
||||
|
||||
// import { signedIn } from '$lib/stores';
|
||||
|
||||
// export async function load({ session }) {
|
||||
// if (session.authenticated) {
|
||||
// signedIn.set(true);
|
||||
// }
|
||||
// return {};
|
||||
// }
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import Footer from '$lib/footer.svelte';
|
||||
import { navbarVisible } from '$lib/stores';
|
||||
|
||||
@@ -3,44 +3,7 @@
|
||||
- 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/.
|
||||
-->
|
||||
<script lang="ts" context="module">
|
||||
throw new Error(
|
||||
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
|
||||
);
|
||||
|
||||
// import { signedIn } from '$lib/stores';
|
||||
|
||||
// export async function load({ url, session }) {
|
||||
// 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) {
|
||||
// signedIn.set(true);
|
||||
// }
|
||||
|
||||
// if (quiz_id === null) {
|
||||
// return {
|
||||
// status: 404
|
||||
// };
|
||||
// }
|
||||
// return {
|
||||
// props: {
|
||||
// quiz_id
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
</script>
|
||||
|
||||
<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 { getLocalization } from '$lib/i18n';
|
||||
import { navbarVisible } from '$lib/stores';
|
||||
@@ -73,8 +36,9 @@
|
||||
answer: string;
|
||||
}
|
||||
|
||||
export let quiz_id: string;
|
||||
let data: Data;
|
||||
export let data;
|
||||
let { quiz_id } = data;
|
||||
let quiz_data: Data;
|
||||
|
||||
const get_quiz = async (): Promise<void> => {
|
||||
const response = await fetch(`/api/v1/quiz/get/${quiz_id}`);
|
||||
@@ -90,7 +54,7 @@
|
||||
temp_data.questions[i].type = QuizQuestionType[question.type];
|
||||
}
|
||||
}
|
||||
data = temp_data;
|
||||
quiz_data = temp_data;
|
||||
return;
|
||||
}
|
||||
};
|
||||
@@ -111,8 +75,8 @@
|
||||
/>
|
||||
</svg>
|
||||
{:then _}
|
||||
{#if data !== undefined}
|
||||
<Editor bind:data submit_button_text={$t('words.save')} bind:quiz_id />
|
||||
{#if quiz_data !== undefined}
|
||||
<Editor bind:quiz_data submit_button_text={$t('words.save')} bind:quiz_id />
|
||||
{/if}
|
||||
{:catch err}
|
||||
<div class="text-center">
|
||||
|
||||
@@ -3,21 +3,6 @@
|
||||
- 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/.
|
||||
-->
|
||||
<script context="module" lang="ts">
|
||||
throw new Error(
|
||||
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
|
||||
);
|
||||
|
||||
// import { signedIn } from '$lib/stores';
|
||||
|
||||
// export async function load({ session }) {
|
||||
// if (session.authenticated) {
|
||||
// signedIn.set(true);
|
||||
// }
|
||||
// return {};
|
||||
// }
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { navbarVisible } from '$lib/stores';
|
||||
navbarVisible.set(true);
|
||||
|
||||
@@ -3,31 +3,6 @@
|
||||
- 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/.
|
||||
-->
|
||||
<script context="module" lang="ts">
|
||||
throw new Error(
|
||||
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
|
||||
);
|
||||
|
||||
// import { signedIn } from '$lib/stores';
|
||||
// export async function load({ session }) {
|
||||
// if (!session.authenticated) {
|
||||
// return {
|
||||
// status: 302,
|
||||
// redirect: '/account/login?returnTo=/import'
|
||||
// };
|
||||
// } else {
|
||||
// if (session.authenticated) {
|
||||
// signedIn.set(true);
|
||||
// }
|
||||
// }
|
||||
// return {
|
||||
// props: {
|
||||
// email: session.email
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { getLocalization } from '$lib/i18n';
|
||||
import { navbarVisible, alertModal } from '$lib/stores';
|
||||
|
||||
@@ -3,31 +3,7 @@
|
||||
- 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/.
|
||||
-->
|
||||
<script context="module" lang="ts">
|
||||
throw new Error(
|
||||
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
|
||||
);
|
||||
|
||||
// import { signedIn } from '$lib/stores';
|
||||
|
||||
// export async function load({ url, session }) {
|
||||
// if (session.authenticated) {
|
||||
// signedIn.set(true);
|
||||
// }
|
||||
// const token = url.searchParams.get('pin');
|
||||
// return {
|
||||
// props: {
|
||||
// game_pin: token === null ? '' : token
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
</script>
|
||||
|
||||
<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 JoinGame from '$lib/play/join.svelte';
|
||||
import type { Answer, QuizData } from '$lib/quiz_types';
|
||||
@@ -39,7 +15,8 @@
|
||||
import { QuizQuestionType } from '$lib/quiz_types';
|
||||
|
||||
// Exports
|
||||
export let game_pin: string;
|
||||
export let data;
|
||||
let { game_pin } = data;
|
||||
|
||||
// Types
|
||||
interface GameMeta {
|
||||
|
||||
@@ -3,21 +3,6 @@
|
||||
- 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/.
|
||||
-->
|
||||
<script context="module" lang="ts">
|
||||
throw new Error(
|
||||
'@migration task: Check code was safely removed (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292722)'
|
||||
);
|
||||
|
||||
// import { signedIn } from '$lib/stores';
|
||||
|
||||
// export async function load({ session }) {
|
||||
// if (session.authenticated) {
|
||||
// signedIn.set(true);
|
||||
// }
|
||||
// return {};
|
||||
// }
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { getLocalization } from '$lib/i18n';
|
||||
const { t } = getLocalization();
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
- file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
-->
|
||||
<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 CollapsSection from '$lib/collapsible.svelte';
|
||||
import { createTippy } from 'svelte-tippy';
|
||||
@@ -21,8 +17,8 @@
|
||||
});
|
||||
|
||||
const { t } = getLocalization();
|
||||
export let logged_in: boolean;
|
||||
export let quiz: QuizData;
|
||||
export let data;
|
||||
let { quiz, logged_in }: { quiz: QuizData; logged_in: boolean } = data;
|
||||
|
||||
interface Question {
|
||||
time: string;
|
||||
@@ -133,13 +129,14 @@
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
><path
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
|
||||
/></svg
|
||||
>
|
||||
/>
|
||||
</svg>
|
||||
<span class="text-lg">{question.time}s</span>
|
||||
</p>
|
||||
{#if question.type === QuizQuestionType.ABCD || question.type === undefined}
|
||||
|
||||
Reference in New Issue
Block a user