plum-e2e 2.5.2 → 2.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,15 +17,31 @@
17
17
 
18
18
  import { API_BASE } from '$lib/constants';
19
19
 
20
+ // A misconfigured or not-yet-routed API URL can accept a connection and never
21
+ // respond, rather than refusing outright — a plain fetch() would then hang
22
+ // forever with no error to catch. AUTH_TIMEOUT_MS bounds that so the UI always
23
+ // resolves one way or another instead of leaving the page blank indefinitely.
24
+ const AUTH_TIMEOUT_MS = 8000;
25
+
26
+ async function fetchWithTimeout(url, options = {}) {
27
+ const controller = new AbortController();
28
+ const timer = setTimeout(() => controller.abort(), AUTH_TIMEOUT_MS);
29
+ try {
30
+ return await fetch(url, { ...options, signal: controller.signal });
31
+ } finally {
32
+ clearTimeout(timer);
33
+ }
34
+ }
35
+
20
36
  export async function checkNeedsSetup() {
21
- const res = await fetch(`${API_BASE}/auth/needs-setup`);
37
+ const res = await fetchWithTimeout(`${API_BASE}/auth/needs-setup`);
22
38
  if (!res.ok) return false;
23
39
  const data = await res.json();
24
40
  return data.needsSetup;
25
41
  }
26
42
 
27
43
  export async function setup({ name, email, password }) {
28
- const res = await fetch(`${API_BASE}/auth/setup`, {
44
+ const res = await fetchWithTimeout(`${API_BASE}/auth/setup`, {
29
45
  method: 'POST',
30
46
  headers: { 'Content-Type': 'application/json' },
31
47
  body: JSON.stringify({ name, email, password })
@@ -36,7 +52,7 @@ export async function setup({ name, email, password }) {
36
52
  }
37
53
 
38
54
  export async function login({ email, password }) {
39
- const res = await fetch(`${API_BASE}/auth/login`, {
55
+ const res = await fetchWithTimeout(`${API_BASE}/auth/login`, {
40
56
  method: 'POST',
41
57
  headers: { 'Content-Type': 'application/json' },
42
58
  body: JSON.stringify({ email, password })
@@ -47,7 +63,7 @@ export async function login({ email, password }) {
47
63
  }
48
64
 
49
65
  export async function updateProfile({ token, name, email }) {
50
- const res = await fetch(`${API_BASE}/auth/update-profile`, {
66
+ const res = await fetchWithTimeout(`${API_BASE}/auth/update-profile`, {
51
67
  method: 'PUT',
52
68
  headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
53
69
  body: JSON.stringify({ name, email })
@@ -58,7 +74,7 @@ export async function updateProfile({ token, name, email }) {
58
74
  }
59
75
 
60
76
  export async function changePassword({ token, currentPassword, newPassword }) {
61
- const res = await fetch(`${API_BASE}/auth/change-password`, {
77
+ const res = await fetchWithTimeout(`${API_BASE}/auth/change-password`, {
62
78
  method: 'POST',
63
79
  headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
64
80
  body: JSON.stringify({ currentPassword, newPassword })
@@ -62,4 +62,18 @@
62
62
  </PageShell>
63
63
  <RunnerPanel />
64
64
  {/if}
65
+ {:else}
66
+ <div class="boot-loading">Loading…</div>
65
67
  {/if}
68
+
69
+ <style>
70
+ .boot-loading {
71
+ min-height: 100vh;
72
+ display: flex;
73
+ align-items: center;
74
+ justify-content: center;
75
+ background: var(--bg);
76
+ color: var(--text-muted);
77
+ font-size: 0.875rem;
78
+ }
79
+ </style>
@@ -60,7 +60,9 @@
60
60
  <svelte:head><title>Sign in — Plum</title></svelte:head>
61
61
 
62
62
  <div class="page" data-theme={$theme}>
63
- {#if !checking}
63
+ {#if checking}
64
+ <p class="checking">Checking server…</p>
65
+ {:else}
64
66
  <div class="card">
65
67
  <div class="brand">
66
68
  <span class="brand-serif">Pl</span><span class="brand-sans">um</span>
@@ -116,6 +118,11 @@
116
118
  padding: 1rem;
117
119
  }
118
120
 
121
+ .checking {
122
+ color: var(--text-muted);
123
+ font-size: 0.875rem;
124
+ }
125
+
119
126
  .card {
120
127
  width: 100%;
121
128
  max-width: 380px;
@@ -65,7 +65,9 @@
65
65
  <svelte:head><title>Setup — Plum</title></svelte:head>
66
66
 
67
67
  <div class="page" data-theme={$theme}>
68
- {#if !checking}
68
+ {#if checking}
69
+ <p class="checking">Checking server…</p>
70
+ {:else}
69
71
  <div class="card">
70
72
  <div class="brand">
71
73
  <span class="brand-serif">Pl</span><span class="brand-sans">um</span>
@@ -136,6 +138,11 @@
136
138
  padding: 1rem;
137
139
  }
138
140
 
141
+ .checking {
142
+ color: var(--text-muted);
143
+ font-size: 0.875rem;
144
+ }
145
+
139
146
  .card {
140
147
  width: 100%;
141
148
  max-width: 400px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plum-e2e",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/silverlunah/plum.git"