Release 0.5.8
This commit is contained in:
1 parent
22ae3a68d6
commit
2851c7d936
33 files changed
+1263
-272
No files matched your search
@@ -1,9 +1,10 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { getPresentationView } from '#lib/server/live.js';
|
||||
import { getPresentationChannelView, presentationChannelAccess } from '#lib/server/live.js';
|
||||
|
||||
export const load: PageServerLoad = ({ params }) => {
|
||||
const view = getPresentationView(params.token);
|
||||
if (!view) error(404, 'Präsentationsausgabe nicht gefunden');
|
||||
return { view };
|
||||
export const load: PageServerLoad = ({ params, cookies }) => {
|
||||
const accessKey = cookies.get(`sendewerk-output-${params.token}`) ?? '';
|
||||
const view = presentationChannelAccess(params.token, accessKey)
|
||||
? getPresentationChannelView(params.token)
|
||||
: null;
|
||||
return { view, channelId: params.token };
|
||||
};
|
||||
@@ -5,8 +5,10 @@
|
||||
import type { PageProps } from './$types';
|
||||
|
||||
let { data }: PageProps = $props();
|
||||
let view = $state(untrack(() => data.view));
|
||||
let connection = $state<'connected' | 'waiting' | 'interrupted'>('connected');
|
||||
let view = $state(untrack(() => data.view ?? { revision: -1, content: null }));
|
||||
let connection = $state<'connected' | 'waiting' | 'interrupted'>(
|
||||
untrack(() => (data.view ? 'connected' : 'waiting'))
|
||||
);
|
||||
|
||||
onMount(() => {
|
||||
let stopped = false;
|
||||
@@ -26,8 +28,22 @@
|
||||
}
|
||||
if (!stopped) timer = setTimeout(refresh, connection === 'interrupted' ? 3000 : 1000);
|
||||
}
|
||||
connection = 'waiting';
|
||||
timer = setTimeout(refresh, 500);
|
||||
async function connect() {
|
||||
const accessKey = decodeURIComponent(location.hash.slice(1));
|
||||
if (accessKey) {
|
||||
const response = await fetch(`/heinzlive/${data.channelId}/access`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ key: accessKey })
|
||||
});
|
||||
if (!response.ok) {
|
||||
connection = 'interrupted';
|
||||
return;
|
||||
}
|
||||
}
|
||||
timer = setTimeout(refresh, 0);
|
||||
}
|
||||
void connect();
|
||||
return () => {
|
||||
stopped = true;
|
||||
clearTimeout(timer);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { error, json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { presentationChannelAccess } from '#lib/server/live.js';
|
||||
|
||||
export const POST: RequestHandler = async ({ params, request, cookies, url }) => {
|
||||
const body = (await request.json().catch(() => null)) as { key?: unknown } | null;
|
||||
const accessKey = typeof body?.key === 'string' ? body.key : '';
|
||||
if (!presentationChannelAccess(params.token, accessKey)) {
|
||||
error(404, 'Präsentationsausgabe nicht gefunden');
|
||||
}
|
||||
cookies.set(`sendewerk-output-${params.token}`, accessKey, {
|
||||
path: `/heinzlive/${params.token}`,
|
||||
httpOnly: true,
|
||||
sameSite: 'strict',
|
||||
secure: url.protocol === 'https:'
|
||||
});
|
||||
return json({ success: true }, { headers: { 'Cache-Control': 'no-store' } });
|
||||
};
|
||||
@@ -1,11 +1,13 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { getPresentationMedia } from '#lib/server/live.js';
|
||||
import { getPresentationMedia, presentationChannelAccess } from '#lib/server/live.js';
|
||||
|
||||
export const GET: RequestHandler = async ({ params }) => {
|
||||
const media = await getPresentationMedia(params.token, params.id);
|
||||
export const GET: RequestHandler = async ({ params, cookies }) => {
|
||||
const accessKey = cookies.get(`sendewerk-output-${params.token}`) ?? '';
|
||||
if (!presentationChannelAccess(params.token, accessKey)) error(404, 'Bild nicht gefunden');
|
||||
const media = await getPresentationMedia(accessKey, params.id);
|
||||
if (!media) error(404, 'Bild nicht gefunden');
|
||||
return new Response(media.data, {
|
||||
return new Response(new Uint8Array(media.data), {
|
||||
headers: {
|
||||
'Content-Type': media.mimeType,
|
||||
'Content-Length': String(media.byteSize),
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { getPresentationPreviewImage } from '#lib/server/live.js';
|
||||
import { getPresentationPreviewImage, presentationChannelAccess } from '#lib/server/live.js';
|
||||
|
||||
export const GET: RequestHandler = async ({ params }) => {
|
||||
const image = await getPresentationPreviewImage(params.token);
|
||||
export const GET: RequestHandler = async ({ params, cookies }) => {
|
||||
const accessKey = cookies.get(`sendewerk-output-${params.token}`) ?? '';
|
||||
if (!presentationChannelAccess(params.token, accessKey))
|
||||
error(404, 'Vorschaubild nicht verfügbar');
|
||||
const image = await getPresentationPreviewImage(accessKey);
|
||||
if (!image) error(404, 'Vorschaubild nicht verfügbar');
|
||||
return new Response(new Uint8Array(image.data), {
|
||||
headers: {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { error, json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { getPresentationView } from '#lib/server/live.js';
|
||||
import { getPresentationChannelView, presentationChannelAccess } from '#lib/server/live.js';
|
||||
|
||||
export const GET: RequestHandler = ({ params }) => {
|
||||
const view = getPresentationView(params.token);
|
||||
export const GET: RequestHandler = ({ params, cookies }) => {
|
||||
const accessKey = cookies.get(`sendewerk-output-${params.token}`) ?? '';
|
||||
if (!presentationChannelAccess(params.token, accessKey))
|
||||
error(404, 'Präsentationsausgabe nicht gefunden');
|
||||
const view = getPresentationChannelView(params.token);
|
||||
if (!view) error(404, 'Präsentationsausgabe nicht gefunden');
|
||||
return json(view, { headers: { 'Cache-Control': 'no-store' } });
|
||||
};
|
||||
Reference in new issue
Block a user