Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit ac9d35b

Browse files
committed
run svelte 5 migration
1 parent da14ca9 commit ac9d35b

16 files changed

Lines changed: 106 additions & 56 deletions

src/lib/components/CopyToClipboard.svelte

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
import { delay } from "$lib/delay";
33
import ErrorMessage from "./ErrorMessage.svelte";
44
5-
export let text: string;
6-
export let label: string;
5+
interface Props {
6+
text: string;
7+
label: string;
8+
}
9+
10+
let { text, label }: Props = $props();
711
8-
let copied = false;
12+
let copied = $state(false);
913
let error: string | null = null;
1014
1115
async function copyToClipboard(text: string) {
@@ -21,7 +25,7 @@
2125
}
2226
</script>
2327

24-
<button type="button" on:click={() => copyToClipboard(text)}>
28+
<button type="button" onclick={() => copyToClipboard(text)}>
2529
{#if copied}
2630
Copied
2731
{:else}

src/lib/components/CreateRecipientForm.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<script lang="ts">
2+
import { preventDefault } from "svelte/legacy";
3+
24
import { publicKeyStore } from "$lib/public_key_store";
35
4-
let recipientName = "";
6+
let recipientName = $state("");
57
68
function createRecipient() {
79
publicKeyStore.update((current) => {
@@ -17,7 +19,7 @@
1719
<article>
1820
<header>Create recipient</header>
1921

20-
<form on:submit|preventDefault={createRecipient}>
22+
<form onsubmit={preventDefault(createRecipient)}>
2123
<input name="recipient_name" required placeholder="Recipient name" bind:value={recipientName} />
2224
<button type="submit">Create</button>
2325
</form>

src/lib/components/ErrorMessage.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<script lang="ts">
2-
export let error: string;
2+
interface Props {
3+
error: string;
4+
}
5+
6+
let { error }: Props = $props();
37
</script>
48

59
<article class="error-message">

src/lib/components/ImportPublicKeys.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { publicKeyStore, type PublicKeyStore } from "$lib/public_key_store";
44
import { get } from "svelte/store";
55
6-
let error: string | null;
6+
let error: string | undefined = $state();
77
88
interface RepositoryTree {
99
tree: GithubFile[];
@@ -24,7 +24,7 @@
2424
}
2525
2626
async function loadPublicKeys() {
27-
error = null;
27+
error = undefined;
2828
const response = await fetch("https://api.github.com/repos/symbiolab/age-public-keys/git/trees/main?recursive=0");
2929
3030
if (!response.ok) {
@@ -75,7 +75,7 @@
7575
<article>
7676
<header>Import symbiolab public keys</header>
7777
<p>Import will overwrite existing symbiolab recipients. Recipients that are not part of symbiolab are left intact.</p>
78-
<button on:click={loadPublicKeys}>Import</button>
78+
<button onclick={loadPublicKeys}>Import</button>
7979
{#if error != null}
8080
<ErrorMessage {error} />
8181
{/if}

src/lib/components/Message.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<script lang="ts">
2-
export let message: string;
2+
interface Props {
3+
message: string;
4+
}
5+
6+
let { message }: Props = $props();
37
</script>
48

59
<article>
Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
<script lang="ts">
2+
import { run } from "svelte/legacy";
3+
24
import { get_public_key_for_private_key } from "rage-webassembly";
35
import ErrorMessage from "./ErrorMessage.svelte";
46
5-
export let name: string;
6-
export let privateKey: string;
7-
export let handleDelete: (name: string) => void;
8-
let publicKey: string | null = null;
9-
let error: string | null = null;
7+
interface Props {
8+
name: string;
9+
privateKey: string;
10+
handleDelete: (name: string) => void;
11+
}
12+
13+
let { name, privateKey, handleDelete }: Props = $props();
14+
let publicKey: string | null = $state(null);
15+
let error: string | null = $state(null);
1016
1117
function getPublicKeyForPrivateKey(key: string) {
1218
error = null;
@@ -18,7 +24,9 @@
1824
}
1925
}
2026
21-
$: getPublicKeyForPrivateKey(privateKey);
27+
run(() => {
28+
getPublicKeyForPrivateKey(privateKey);
29+
});
2230
</script>
2331

2432
<article>
@@ -29,5 +37,5 @@
2937
{#if error != null}
3038
<ErrorMessage {error} />
3139
{/if}
32-
<button on:click={() => handleDelete(name)}>Delete</button>
40+
<button onclick={() => handleDelete(name)}>Delete</button>
3341
</article>

src/lib/components/PublicKeyPicker.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<script lang="ts">
22
import { sortedKeys } from "$lib/public_key_store";
33
import { get } from "svelte/store";
4-
export let selection: string[] = [];
4+
interface Props {
5+
selection?: string[];
6+
}
7+
8+
let { selection = $bindable([]) }: Props = $props();
59
610
function selectAll() {
711
selection = [...get(sortedKeys)];
@@ -23,4 +27,4 @@
2327
{/each}
2428
</fieldset>
2529

26-
<button on:click={selectAll} type="button">Select all</button>
30+
<button onclick={selectAll} type="button">Select all</button>

src/lib/components/RecipientCard.svelte

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
<script lang="ts">
2+
import { preventDefault } from "svelte/legacy";
3+
24
import { publicKeyStore } from "$lib/public_key_store";
3-
export let recipientName: string;
5+
interface Props {
6+
recipientName: string;
7+
}
8+
9+
let { recipientName }: Props = $props();
410
5-
let publicKeyToAdd = "";
11+
let publicKeyToAdd = $state("");
612
713
function addKey() {
814
publicKeyStore.update((current) => {
@@ -43,16 +49,16 @@
4349
{#each $publicKeyStore[recipientName] as key}
4450
<div class="key">
4551
<pre>{key}</pre>
46-
<button on:click={() => deletePublicKey(key)} type="button">Delete</button>
52+
<button onclick={() => deletePublicKey(key)} type="button">Delete</button>
4753
</div>
4854
{/each}
4955

5056
<footer>
51-
<form on:submit|preventDefault={addKey} class="add-key-form">
57+
<form onsubmit={preventDefault(addKey)} class="add-key-form">
5258
<input name="public_key" required placeholder="Public key" bind:value={publicKeyToAdd} />
5359
<button type="submit">add</button>
5460
</form>
55-
<button type="button" on:click={deleteRecipient}>Delete Recipient</button>
61+
<button type="button" onclick={deleteRecipient}>Delete Recipient</button>
5662
</footer>
5763
</article>
5864
{/if}

src/routes/+layout.svelte

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22
import "@fontsource/fira-sans";
33
import "@fontsource/fira-code";
44
import "$lib/scss/global.scss";
5+
interface Props {
6+
children?: import("svelte").Snippet;
7+
}
8+
9+
let { children }: Props = $props();
510
</script>
611

712
<div class="title">
813
<a href="/">fbrage</a>
914
</div>
1015
<main>
11-
<slot />
16+
{@render children?.()}
1217
</main>
1318

1419
<style lang="scss">

src/routes/decrypt-file/+page.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<script lang="ts">
2+
import { preventDefault } from "svelte/legacy";
3+
24
import { decrypt_file } from "rage-webassembly";
35
import { get } from "svelte/store";
46
import ErrorMessage from "$lib/components/ErrorMessage.svelte";
57
import { onDestroy } from "svelte";
68
import { privateKeyStore } from "$lib/private_key_store";
79
810
let file: File | null;
9-
let error: string | null = null;
11+
let error: string | null = $state(null);
1012
let objectURL: string | null = null;
1113
1214
onDestroy(() => {
@@ -54,8 +56,8 @@
5456

5557
<p>Available private keys: {Object.keys($privateKeyStore).length}</p>
5658

57-
<form on:submit|preventDefault={handleSubmit}>
58-
<input required type="file" on:change={handleChange} />
59+
<form onsubmit={preventDefault(handleSubmit)}>
60+
<input required type="file" onchange={handleChange} />
5961
<button>Decrypt</button>
6062
</form>
6163

0 commit comments

Comments
 (0)