Spaces:
Runtime error
Runtime error
fiz about and depecrated api
Browse files
frontend/src/lib/About.svelte
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
<script lang="ts">
|
2 |
import LiveBlocks from '$lib/Icons/LiveBlocks.svelte';
|
|
|
3 |
export let classList = '';
|
|
|
4 |
</script>
|
5 |
|
6 |
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
@@ -9,9 +11,15 @@
|
|
9 |
class="fixed {classList} w-screen top-0 left-0 bottom-0 right-0 max-h-screen z-50 items-center justify-center bg-black text-white bg-opacity-90 px-3 overflow-y-scroll"
|
10 |
>
|
11 |
<div class="max-w-md">
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
<h2 class="font-bold text-xl font-mono mb-8">Stable Difussion Multiplayer</h2>
|
13 |
<p>
|
14 |
-
Hugging Face face GPU Spaces <a
|
15 |
href="https://huggingface.co/docs/hub/spaces-gpus"
|
16 |
class="text-blue-400 hover:text-blue-600 underline"
|
17 |
>https://huggingface.co/docs/hub/spaces-gpus</a
|
|
|
1 |
<script lang="ts">
|
2 |
import LiveBlocks from '$lib/Icons/LiveBlocks.svelte';
|
3 |
+
import LoadingIcon from './Icons/LoadingIcon.svelte';
|
4 |
export let classList = '';
|
5 |
+
export let loading = false;
|
6 |
</script>
|
7 |
|
8 |
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
|
11 |
class="fixed {classList} w-screen top-0 left-0 bottom-0 right-0 max-h-screen z-50 items-center justify-center bg-black text-white bg-opacity-90 px-3 overflow-y-scroll"
|
12 |
>
|
13 |
<div class="max-w-md">
|
14 |
+
{#if loading}
|
15 |
+
<div class="text-4xl text-white flex items-center mb-4">
|
16 |
+
<LoadingIcon classList={'inline-block animate-spin p-1 mr-2'} />
|
17 |
+
<h1 class="font-bold inline-block">Loading...</h1>
|
18 |
+
</div>
|
19 |
+
{/if}
|
20 |
<h2 class="font-bold text-xl font-mono mb-8">Stable Difussion Multiplayer</h2>
|
21 |
<p>
|
22 |
+
Powered by Hugging Face face GPU Spaces <a
|
23 |
href="https://huggingface.co/docs/hub/spaces-gpus"
|
24 |
class="text-blue-400 hover:text-blue-600 underline"
|
25 |
>https://huggingface.co/docs/hub/spaces-gpus</a
|
frontend/src/lib/App.svelte
CHANGED
@@ -14,28 +14,10 @@
|
|
14 |
import { useMyPresence, useObject, useOthers } from '$lib/liveblocks';
|
15 |
import { base64ToBlob, uploadImage } from '$lib/utils';
|
16 |
import { nanoid } from 'nanoid';
|
17 |
-
import { CANVAS_SIZE, FRAME_SIZE } from '$lib/constants';
|
18 |
-
|
19 |
-
/**
|
20 |
-
* The main Liveblocks code for the example.
|
21 |
-
* Check in src/routes/index.svelte to see the setup code.
|
22 |
-
*/
|
23 |
|
24 |
const myPresence = useMyPresence();
|
25 |
const others = useOthers();
|
26 |
|
27 |
-
// Set a default value for presence
|
28 |
-
const initialPresence: Presence = {
|
29 |
-
cursor: null,
|
30 |
-
frame: {
|
31 |
-
x: CANVAS_SIZE.width / 2 - FRAME_SIZE / 2,
|
32 |
-
y: CANVAS_SIZE.height / 2 - FRAME_SIZE / 2
|
33 |
-
},
|
34 |
-
status: Status.dragging,
|
35 |
-
currentPrompt: ''
|
36 |
-
};
|
37 |
-
myPresence.update(initialPresence);
|
38 |
-
|
39 |
function getKey(position: { x: number; y: number }): PromptImgKey {
|
40 |
return `${position.x}_${position.y}`;
|
41 |
}
|
|
|
14 |
import { useMyPresence, useObject, useOthers } from '$lib/liveblocks';
|
15 |
import { base64ToBlob, uploadImage } from '$lib/utils';
|
16 |
import { nanoid } from 'nanoid';
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
const myPresence = useMyPresence();
|
19 |
const others = useOthers();
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
function getKey(position: { x: number; y: number }): PromptImgKey {
|
22 |
return `${position.x}_${position.y}`;
|
23 |
}
|
frontend/src/lib/liveblocks/RoomProvider.svelte
CHANGED
@@ -3,29 +3,30 @@
|
|
3 |
https://liveblocks.io/docs/api-reference/liveblocks-react#RoomProvider
|
4 |
-->
|
5 |
<script lang="ts">
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
22 |
|
23 |
-
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
</script>
|
30 |
|
31 |
<slot />
|
|
|
3 |
https://liveblocks.io/docs/api-reference/liveblocks-react#RoomProvider
|
4 |
-->
|
5 |
<script lang="ts">
|
6 |
+
// @ts-nocheck
|
7 |
+
import { clientSymbol, roomSymbol } from './symbols';
|
8 |
+
import type { Client, Room } from '@liveblocks/client';
|
9 |
+
import { getContext, onDestroy, setContext } from 'svelte';
|
10 |
+
import type { Presence } from '$lib/types';
|
11 |
|
12 |
+
export let id: string;
|
13 |
+
export let initialPresence: Presence = {};
|
14 |
|
15 |
+
if (!id) {
|
16 |
+
throw new Error('RoomProvider requires an id');
|
17 |
+
}
|
18 |
|
19 |
+
const client = getContext<Client>(clientSymbol);
|
20 |
|
21 |
+
if (client) {
|
22 |
+
const room = client.enter(id, { initialPresence });
|
23 |
|
24 |
+
setContext<Room>(roomSymbol, room);
|
25 |
|
26 |
+
onDestroy(() => {
|
27 |
+
client.leave(id);
|
28 |
+
});
|
29 |
+
}
|
30 |
</script>
|
31 |
|
32 |
<slot />
|
frontend/src/routes/+/+page.svelte
CHANGED
@@ -9,7 +9,8 @@
|
|
9 |
import { PUBLIC_API_BASE } from '$env/static/public';
|
10 |
import { selectedRoomID, toggleAbout } from '$lib/store';
|
11 |
import type { RoomResponse } from '$lib/types';
|
12 |
-
import { MAX_CAPACITY } from '$lib/constants';
|
|
|
13 |
|
14 |
let loading = true;
|
15 |
let client: Client;
|
@@ -24,6 +25,7 @@
|
|
24 |
|
25 |
updateRooms();
|
26 |
});
|
|
|
27 |
async function updateRooms() {
|
28 |
loading = true;
|
29 |
const roomidParam = new URLSearchParams(window.location.search).get('roomid');
|
@@ -42,14 +44,27 @@
|
|
42 |
loading = false;
|
43 |
return { rooms };
|
44 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
</script>
|
46 |
|
47 |
-
<About
|
|
|
|
|
|
|
|
|
48 |
|
49 |
{#if !loading}
|
50 |
<LiveblocksProvider {client}>
|
51 |
{#if roomId}
|
52 |
-
<RoomProvider id={roomId}>
|
53 |
<App />
|
54 |
</RoomProvider>
|
55 |
{:else}
|
@@ -59,8 +74,4 @@
|
|
59 |
</div>
|
60 |
{/if}
|
61 |
</LiveblocksProvider>
|
62 |
-
{:else}
|
63 |
-
<div class="flex flex-col items-center justify-center h-full">
|
64 |
-
<h1 class="text-2xl font-bold">Loading...</h1>
|
65 |
-
</div>
|
66 |
{/if}
|
|
|
9 |
import { PUBLIC_API_BASE } from '$env/static/public';
|
10 |
import { selectedRoomID, toggleAbout } from '$lib/store';
|
11 |
import type { RoomResponse } from '$lib/types';
|
12 |
+
import { MAX_CAPACITY, CANVAS_SIZE, FRAME_SIZE } from '$lib/constants';
|
13 |
+
import { Status } from '$lib/types';
|
14 |
|
15 |
let loading = true;
|
16 |
let client: Client;
|
|
|
25 |
|
26 |
updateRooms();
|
27 |
});
|
28 |
+
|
29 |
async function updateRooms() {
|
30 |
loading = true;
|
31 |
const roomidParam = new URLSearchParams(window.location.search).get('roomid');
|
|
|
44 |
loading = false;
|
45 |
return { rooms };
|
46 |
}
|
47 |
+
const initialPresence = {
|
48 |
+
cursor: null,
|
49 |
+
frame: {
|
50 |
+
x: CANVAS_SIZE.width / 2 - FRAME_SIZE / 2,
|
51 |
+
y: CANVAS_SIZE.height / 2 - FRAME_SIZE / 2
|
52 |
+
},
|
53 |
+
status: Status.dragging,
|
54 |
+
currentPrompt: ''
|
55 |
+
};
|
56 |
</script>
|
57 |
|
58 |
+
<About
|
59 |
+
classList={$toggleAbout || loading ? 'flex' : 'hidden'}
|
60 |
+
on:click={() => ($toggleAbout = false)}
|
61 |
+
{loading}
|
62 |
+
/>
|
63 |
|
64 |
{#if !loading}
|
65 |
<LiveblocksProvider {client}>
|
66 |
{#if roomId}
|
67 |
+
<RoomProvider id={roomId} {initialPresence}>
|
68 |
<App />
|
69 |
</RoomProvider>
|
70 |
{:else}
|
|
|
74 |
</div>
|
75 |
{/if}
|
76 |
</LiveblocksProvider>
|
|
|
|
|
|
|
|
|
77 |
{/if}
|
frontend/src/routes/+page.svelte
CHANGED
@@ -9,7 +9,8 @@
|
|
9 |
import { PUBLIC_API_BASE } from '$env/static/public';
|
10 |
import { selectedRoomID, toggleAbout } from '$lib/store';
|
11 |
import type { RoomResponse } from '$lib/types';
|
12 |
-
import { MAX_CAPACITY } from '$lib/constants';
|
|
|
13 |
|
14 |
let loading = true;
|
15 |
let client: Client;
|
@@ -24,6 +25,7 @@
|
|
24 |
|
25 |
updateRooms();
|
26 |
});
|
|
|
27 |
async function updateRooms() {
|
28 |
loading = true;
|
29 |
const roomidParam = new URLSearchParams(window.location.search).get('roomid');
|
@@ -42,14 +44,27 @@
|
|
42 |
loading = false;
|
43 |
return { rooms };
|
44 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
</script>
|
46 |
|
47 |
-
<About
|
|
|
|
|
|
|
|
|
48 |
|
49 |
{#if !loading}
|
50 |
<LiveblocksProvider {client}>
|
51 |
{#if roomId}
|
52 |
-
<RoomProvider id={roomId}>
|
53 |
<App />
|
54 |
</RoomProvider>
|
55 |
{:else}
|
@@ -59,8 +74,4 @@
|
|
59 |
</div>
|
60 |
{/if}
|
61 |
</LiveblocksProvider>
|
62 |
-
{:else}
|
63 |
-
<div class="flex flex-col items-center justify-center h-full">
|
64 |
-
<h1 class="text-2xl font-bold">Loading...</h1>
|
65 |
-
</div>
|
66 |
{/if}
|
|
|
9 |
import { PUBLIC_API_BASE } from '$env/static/public';
|
10 |
import { selectedRoomID, toggleAbout } from '$lib/store';
|
11 |
import type { RoomResponse } from '$lib/types';
|
12 |
+
import { MAX_CAPACITY, CANVAS_SIZE, FRAME_SIZE } from '$lib/constants';
|
13 |
+
import { Status } from '$lib/types';
|
14 |
|
15 |
let loading = true;
|
16 |
let client: Client;
|
|
|
25 |
|
26 |
updateRooms();
|
27 |
});
|
28 |
+
|
29 |
async function updateRooms() {
|
30 |
loading = true;
|
31 |
const roomidParam = new URLSearchParams(window.location.search).get('roomid');
|
|
|
44 |
loading = false;
|
45 |
return { rooms };
|
46 |
}
|
47 |
+
const initialPresence = {
|
48 |
+
cursor: null,
|
49 |
+
frame: {
|
50 |
+
x: CANVAS_SIZE.width / 2 - FRAME_SIZE / 2,
|
51 |
+
y: CANVAS_SIZE.height / 2 - FRAME_SIZE / 2
|
52 |
+
},
|
53 |
+
status: Status.dragging,
|
54 |
+
currentPrompt: ''
|
55 |
+
};
|
56 |
</script>
|
57 |
|
58 |
+
<About
|
59 |
+
classList={$toggleAbout || loading ? 'flex' : 'hidden'}
|
60 |
+
on:click={() => ($toggleAbout = false)}
|
61 |
+
{loading}
|
62 |
+
/>
|
63 |
|
64 |
{#if !loading}
|
65 |
<LiveblocksProvider {client}>
|
66 |
{#if roomId}
|
67 |
+
<RoomProvider id={roomId} {initialPresence}>
|
68 |
<App />
|
69 |
</RoomProvider>
|
70 |
{:else}
|
|
|
74 |
</div>
|
75 |
{/if}
|
76 |
</LiveblocksProvider>
|
|
|
|
|
|
|
|
|
77 |
{/if}
|