@axium/client 0.40.2 → 0.42.0

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.
package/dist/access.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { AccessControl, AccessTarget } from '@axium/core';
2
- export declare function updateACL(itemType: string, itemId: string, target: AccessTarget, permissions: Partial<Record<string, any>>): Promise<AccessControl>;
2
+ export declare function updateACL(itemType: string, itemId: string, target: AccessTarget, permissions: Record<string, boolean>): Promise<AccessControl>;
3
3
  export declare function getACL(itemType: string, itemId: string): Promise<AccessControl[]>;
4
4
  export declare function addToACL(itemType: string, itemId: string, target: AccessTarget): Promise<AccessControl>;
5
5
  export declare function removeFromACL(itemType: string, itemId: string, target: AccessTarget): Promise<AccessControl>;
@@ -48,12 +48,6 @@ export declare const meta: Handle<z.ZodObject<{
48
48
  isSuspended: z.ZodBoolean;
49
49
  }, z.core.$strip>;
50
50
  }, z.core.$strip>;
51
- apps: z.ZodArray<z.ZodObject<{
52
- id: z.ZodString;
53
- name: z.ZodOptional<z.ZodString>;
54
- image: z.ZodOptional<z.ZodString>;
55
- icon: z.ZodOptional<z.ZodString>;
56
- }, z.core.$strip>>;
57
51
  }, z.core.$loose>>;
58
52
  export declare const sync: Handle<z.ZodObject<{
59
53
  objects: z.ZodArray<z.ZodObject<{
package/dist/cli/cache.js CHANGED
@@ -1,4 +1,4 @@
1
- import { App, Session, SyncState, User } from '@axium/core';
1
+ import { Session, SyncState, User } from '@axium/core';
2
2
  import * as io from 'ioium/node';
3
3
  import { existsSync, mkdirSync, statSync, unlinkSync } from 'node:fs';
4
4
  import { homedir } from 'node:os';
@@ -76,11 +76,10 @@ export const meta = useAt({
76
76
  schema: z.looseObject({
77
77
  fetched: z.int(),
78
78
  session: Session.extend({ user: User }),
79
- apps: App.array(),
80
79
  }),
81
80
  async update() {
82
- const [session, apps] = await io.track('Fetching metadata', Promise.all([getCurrentSession(), fetchAPI('GET', 'apps')]));
83
- return { fetched: Date.now(), session, apps };
81
+ const session = await io.track('Fetching metadata', getCurrentSession());
82
+ return { fetched: Date.now(), session };
84
83
  },
85
84
  isValid: meta => meta.fetched + _dayMs > Date.now(),
86
85
  });
package/dist/web/hooks.js CHANGED
@@ -4,6 +4,7 @@ import { themeStyles } from '../themes.js';
4
4
  import { extendCurrentSession, getCurrentSession } from '../user.js';
5
5
  import { loadFeatures } from './features.js';
6
6
  import { loadLocale } from './locales.js';
7
+ import * as push from './push.js';
7
8
  import * as pwa from './pwa.js';
8
9
  const day = 86400_000;
9
10
  export async function init() {
@@ -13,6 +14,8 @@ export async function init() {
13
14
  void pwa.register().catch(e => console.debug('Failed to register service worker:', errorText(e)));
14
15
  else
15
16
  void pwa.unregister().catch(() => { });
17
+ if (session && feature('pwa'))
18
+ void push.sync().catch(e => console.debug('Failed to sync push subscription:', errorText(e)));
16
19
  await loadLocale().catch(() => { });
17
20
  if (session && session.expires.getTime() < Date.now() + day)
18
21
  void extendCurrentSession(session.userId).catch(() => console.debug('Failed to extend current session'));
@@ -4,5 +4,6 @@ export * as controls from './controls.js';
4
4
  export * from './features.js';
5
5
  export * from './locales.js';
6
6
  export * from './mobile.js';
7
+ export * as push from './push.js';
7
8
  export * as pwa from './pwa.js';
8
9
  export * from './utils.js';
package/dist/web/index.js CHANGED
@@ -4,5 +4,6 @@ export * as controls from './controls.js';
4
4
  export * from './features.js';
5
5
  export * from './locales.js';
6
6
  export * from './mobile.js';
7
+ export * as push from './push.js';
7
8
  export * as pwa from './pwa.js';
8
9
  export * from './utils.js';
@@ -0,0 +1,8 @@
1
+ export declare const supported: boolean;
2
+ /** This device's push subscription, if it has one. */
3
+ export declare function getSubscription(): Promise<PushSubscription | null>;
4
+ /** Ask for permission, then subscribe this device for the current session. */
5
+ export declare function subscribe(): Promise<PushSubscription>;
6
+ export declare function unsubscribe(): Promise<void>;
7
+ /** Register an existing subscription with the current session, e.g. after logging in again. */
8
+ export declare function sync(): Promise<void>;
@@ -0,0 +1,37 @@
1
+ import { fetchAPI } from '../requests.js';
2
+ export const supported = typeof window != 'undefined' && 'serviceWorker' in navigator && 'PushManager' in window && 'Notification' in window;
3
+ /** This device's push subscription, if it has one. */
4
+ export async function getSubscription() {
5
+ if (!supported)
6
+ return null;
7
+ const registration = await navigator.serviceWorker.getRegistration();
8
+ return (await registration?.pushManager.getSubscription()) ?? null;
9
+ }
10
+ /** Ask for permission, then subscribe this device for the current session. */
11
+ export async function subscribe() {
12
+ if (!supported)
13
+ throw new Error('Push notifications are not supported by this browser');
14
+ const { publicKey } = await fetchAPI('GET', 'push');
15
+ if (!publicKey)
16
+ throw new Error('Push notifications are not set up on this server');
17
+ if ((await Notification.requestPermission()) != 'granted')
18
+ throw new Error('Notification permission was denied');
19
+ const { pushManager } = await navigator.serviceWorker.ready;
20
+ const subscription = await pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: publicKey });
21
+ await fetchAPI('PUT', 'session/push', subscription.toJSON());
22
+ return subscription;
23
+ }
24
+ export async function unsubscribe() {
25
+ const subscription = await getSubscription();
26
+ if (!subscription)
27
+ return;
28
+ await fetchAPI('DELETE', 'session/push', { endpoint: subscription.endpoint });
29
+ await subscription.unsubscribe();
30
+ }
31
+ /** Register an existing subscription with the current session, e.g. after logging in again. */
32
+ export async function sync() {
33
+ const subscription = await getSubscription();
34
+ if (!subscription || Notification.permission != 'granted')
35
+ return;
36
+ await fetchAPI('PUT', 'session/push', subscription.toJSON());
37
+ }
@@ -63,6 +63,38 @@ globalThis.addEventListener('fetch', event => {
63
63
  return;
64
64
  event.respondWith(maybeCached(request));
65
65
  });
66
+ globalThis.addEventListener('push', event => {
67
+ const notification = event.data?.json();
68
+ if (!notification?.title)
69
+ return;
70
+ const { title, url, ...options } = notification;
71
+ event.waitUntil(globalThis.registration.showNotification(title, { ...options, data: { url } }));
72
+ });
73
+ async function open(url) {
74
+ const windows = await globalThis.clients.matchAll({ type: 'window', includeUncontrolled: true });
75
+ const existing = windows.find(client => client.url == url);
76
+ if (existing)
77
+ await existing.focus();
78
+ else
79
+ await globalThis.clients.openWindow(url);
80
+ }
81
+ globalThis.addEventListener('notificationclick', event => {
82
+ event.notification.close();
83
+ const url = new URL(event.notification.data?.url ?? '/', location.origin).href;
84
+ event.waitUntil(open(url));
85
+ });
86
+ async function resubscribe(event) {
87
+ const subscription = event.newSubscription ??
88
+ (event.oldSubscription && (await globalThis.registration.pushManager.subscribe(event.oldSubscription.options)));
89
+ if (!subscription)
90
+ return;
91
+ await fetch(resolve('api/session/push'), {
92
+ method: 'PUT',
93
+ headers: { 'Content-Type': 'application/json' },
94
+ body: JSON.stringify(subscription),
95
+ });
96
+ }
97
+ globalThis.addEventListener('pushsubscriptionchange', event => event.waitUntil(resubscribe(event)));
66
98
  globalThis.addEventListener('message', (event) => {
67
99
  if (!event.data)
68
100
  console.warn('Ignoring invalid message (no data)');
@@ -1,13 +1,16 @@
1
1
  <script lang="ts">
2
2
  import { addToACL, getACL, removeFromACL, text, updateACL, userInfo } from '@axium/client';
3
- import type { AccessControllable, UserPublic } from '@axium/core';
4
- import { checkAndMatchACL, getTarget, pickPermissions } from '@axium/core';
3
+ import type { AccessControl, AccessControllable, UserPublic } from '@axium/core';
4
+ import { checkAndMatchACL, getTarget, impliedPermissions, pickPermissions, resolvePermissions } from '@axium/core';
5
+ import { getAccessControlConfig } from '@axium/core/plugins';
5
6
  import type { HTMLDialogAttributes } from 'svelte/elements';
6
7
  import Discovery, * as discovery from './Discovery.svelte';
8
+ import FormDialog from './FormDialog.svelte';
7
9
  import Icon from './Icon.svelte';
8
10
  import UserCard from './UserCard.svelte';
9
11
  import { closeOnBackGesture } from './attachments/gestures.js';
10
- import { toast, toastStatus } from './toast.js';
12
+ import { confirm } from './dialogs.js';
13
+ import { toast } from './toast.js';
11
14
 
12
15
  interface Props extends HTMLDialogAttributes {
13
16
  user?: UserPublic;
@@ -19,7 +22,55 @@
19
22
 
20
23
  const acl = $state(item.acl ?? (await getACL(itemType, item.id)));
21
24
 
22
- const editable = $derived(!!user && (item.userId === user.id || !checkAndMatchACL(item.acl || [], user, { manage: true }).size));
25
+ const config = $derived(getAccessControlConfig(itemType));
26
+ const presets = $derived(Object.keys(config?.presets ?? {}));
27
+
28
+ const editable = $derived(!!user && (item.userId === user.id || !checkAndMatchACL(acl, user, { manage: true }).size));
29
+
30
+ let customDialog = $state<HTMLDialogElement>(),
31
+ customizing = $state<AccessControl>(),
32
+ draft = $state<Record<string, boolean>>({});
33
+
34
+ function permissionNames(control: AccessControl): string[] {
35
+ return Object.keys(config?.permissions ?? pickPermissions(control));
36
+ }
37
+
38
+ function presetOf(control: AccessControl): string | undefined {
39
+ return Object.entries(config?.presets ?? {}).find(([, granted]) =>
40
+ permissionNames(control).every(name => !!control[name] == granted.includes(name))
41
+ )?.[0];
42
+ }
43
+
44
+ /** Whether a permission is granted because another granted permission implies it */
45
+ function isImplied(permissions: Record<string, unknown>, name: string): boolean {
46
+ if (!config) return false;
47
+ return Object.keys(permissions).some(other => other != name && permissions[other] && impliedPermissions(config, other).has(name));
48
+ }
49
+
50
+ function permissionText(name: string): string {
51
+ return text(`permission.${itemType}.${name}`, { $default: name });
52
+ }
53
+
54
+ function presetText(name: string): string {
55
+ return text(`preset.${itemType}.${name}`, { $default: name });
56
+ }
57
+
58
+ function summary(control: AccessControl): string {
59
+ const preset = presetOf(control);
60
+ if (preset) return presetText(preset);
61
+ const granted = permissionNames(control).filter(name => control[name]);
62
+ return granted.length ? granted.map(permissionText).join(', ') : text('AccessControlDialog.no_access');
63
+ }
64
+
65
+ async function update(control: AccessControl, permissions: Record<string, boolean>) {
66
+ Object.assign(control, await updateACL(itemType, item.id, getTarget(control), permissions));
67
+ }
68
+
69
+ function customize(control: AccessControl) {
70
+ customizing = control;
71
+ draft = Object.fromEntries(permissionNames(control).map(name => [name, !!control[name]]));
72
+ customDialog?.showModal();
73
+ }
23
74
  </script>
24
75
 
25
76
  <dialog bind:this={dialog} {...rest} onclick={e => e.stopPropagation()} {@attach closeOnBackGesture}>
@@ -29,90 +80,123 @@
29
80
  <h3>{text('AccessControlDialog.title')}</h3>
30
81
  {/if}
31
82
 
32
- <div class="AccessControl text">
33
- {#if item.user}
34
- <UserCard user={item.user} />
35
- {:else if item}
36
- {#await userInfo(item.userId) then user}<UserCard {user} />{:catch}<i>{text('generic.unknown')}</i>{/await}
37
- {/if}
38
- <span>{text('AccessControlDialog.owner')}</span>
39
- </div>
40
-
41
- {#each acl as control, i (control.userId || control.role || control.tag)}
42
- {const update = (key: string) => async (e: Event & { currentTarget: HTMLInputElement }) => {
43
- try {
44
- const updated = await updateACL(itemType, item.id, getTarget(control), { [key]: e.currentTarget.checked });
45
- Object.assign(control, updated);
46
- } catch (e) {
47
- toast('error', e);
48
- }
49
- }}
83
+ <div class="entries">
50
84
  <div class="AccessControl">
51
85
  <div class="target">
52
- {#if control.userId}
53
- <UserCard user={(control.user ||= await userInfo(control.userId))} />
54
- {:else if control.role}
55
- <span class="icon-text">
56
- <Icon i="at" />
57
- <span>{control.role}</span>
58
- </span>
59
- {:else if control.tag}
60
- <span class="icon-text">
61
- <Icon i="hashtag" />
62
- <span>{control.tag}</span>
63
- </span>
86
+ {#if item.user}
87
+ <UserCard user={item.user} self={item.userId == user?.id} you />
88
+ {:else}
89
+ {#await userInfo(item.userId) then owner}
90
+ <UserCard user={owner} self={item.userId == user?.id} you />
91
+ {:catch}
92
+ <i>{text('generic.unknown')}</i>
93
+ {/await}
94
+ {/if}
95
+ </div>
96
+ <span class="access">{text('AccessControlDialog.owner')}</span>
97
+ </div>
98
+
99
+ {#each acl as control (getTarget(control))}
100
+ {const preset = $derived(presetOf(control))}
101
+ <div class="AccessControl">
102
+ <div class="target">
103
+ {#if control.userId}
104
+ <UserCard user={(control.user ||= await userInfo(control.userId))} self={control.userId == user?.id} you />
105
+ {:else if control.role}
106
+ <span class="icon-text">
107
+ <Icon i="at" />
108
+ <span>{control.role}</span>
109
+ </span>
110
+ {:else if control.tag}
111
+ <span class="icon-text">
112
+ <Icon i="hashtag" />
113
+ <span>{control.tag}</span>
114
+ </span>
115
+ {:else}
116
+ <span class="icon-text">
117
+ <Icon i="globe" />
118
+ <span>{text('AccessControlDialog.public_target')}</span>
119
+ </span>
120
+ {/if}
121
+ </div>
122
+
123
+ {#if !editable}
124
+ <span class="access">{summary(control)}</span>
125
+ {:else if presets.length}
126
+ <select
127
+ class="access"
128
+ value={preset ?? ''}
129
+ onchange={async event => {
130
+ const select = event.currentTarget;
131
+
132
+ if (select.value == 'custom') {
133
+ select.value = preset ?? '';
134
+ customize(control);
135
+ return;
136
+ }
137
+
138
+ const granted = config!.presets[select.value];
139
+ try {
140
+ await update(
141
+ control,
142
+ Object.fromEntries(permissionNames(control).map(name => [name, granted.includes(name)]))
143
+ );
144
+ } catch (error) {
145
+ select.value = presetOf(control) ?? '';
146
+ await toast('error', error);
147
+ }
148
+ }}
149
+ >
150
+ {#each presets as name}
151
+ <option value={name}>{presetText(name)}</option>
152
+ {/each}
153
+ {#if !preset}
154
+ <option value="" disabled>{summary(control)}</option>
155
+ {/if}
156
+ {#if !config?.force_presets}
157
+ <option value="custom">{text('AccessControlDialog.customize')}</option>
158
+ {/if}
159
+ </select>
64
160
  {:else}
65
- <span>{text('AccessControlDialog.public_target')}</span>
161
+ <button class="access" onclick={() => customize(control)}>{summary(control)}</button>
66
162
  {/if}
163
+
67
164
  {#if editable}
68
165
  <button
69
- class="icon-text danger"
70
- onclick={() =>
71
- toastStatus(
72
- removeFromACL(itemType, item.id, getTarget(control)).then(() => acl.splice(i, 1)),
73
- text('AccessControlDialog.toast_removed')
74
- )}
166
+ class="reset remove"
167
+ title={text('AccessControlDialog.remove')}
168
+ onclick={async () => {
169
+ const target = getTarget(control);
170
+
171
+ if (
172
+ control.userId == user?.id &&
173
+ !(await confirm(text('AccessControlDialog.remove_self_confirm'), {
174
+ danger: true,
175
+ confirmText: text('AccessControlDialog.remove'),
176
+ }))
177
+ )
178
+ return;
179
+
180
+ try {
181
+ await removeFromACL(itemType, item.id, target);
182
+ acl.splice(
183
+ acl.findIndex(other => getTarget(other) == target),
184
+ 1
185
+ );
186
+ await toast('success', text('AccessControlDialog.toast_removed'));
187
+ } catch (error) {
188
+ await toast('error', error);
189
+ }
190
+ }}
75
191
  >
76
- <Icon i="user-minus" />
77
- <span>{text('AccessControlDialog.remove')}</span>
192
+ <Icon i="trash" />
78
193
  </button>
79
194
  {/if}
80
195
  </div>
81
- <div class="permissions">
82
- {#each Object.entries(pickPermissions(control) as Record<string, boolean>) as [key, value]}
83
- {const id = $derived(`${item.id}.${getTarget(control)}.${key}`)}
84
- <span class="icon-text">
85
- {#if editable}
86
- <input {id} type="checkbox" onchange={update(key)} />
87
- <label for={id} class="checkbox">
88
- {#if value}<Icon i="check" --size="1.3em" />{/if}
89
- </label>
90
- {:else}
91
- <Icon i={value ? 'check' : 'xmark'} />
92
- {/if}
93
- <span>{text(`permission.${itemType}.${key}`, { $default: key })}</span>
94
- </span>
95
- {/each}
96
- </div>
97
- </div>
98
- {/each}
196
+ {/each}
197
+ </div>
99
198
 
100
199
  {#if editable}
101
- <div class="actions">
102
- {#if !acl.find(c => !c.userId && !c.role && !c.tag)}
103
- <button
104
- class="icon-text"
105
- onclick={() =>
106
- addToACL(itemType, item.id, null)
107
- .then(ac => acl.push(ac))
108
- .catch(e => toast('error', e))}
109
- >
110
- <Icon i="globe" />
111
- <span>{text('AccessControlDialog.add_public')}</span>
112
- </button>
113
- {/if}
114
- </div>
115
-
116
200
  <Discovery
117
201
  onSelect={async ({ target }) => {
118
202
  try {
@@ -120,7 +204,7 @@
120
204
  if (control.userId) control.user = await userInfo(control.userId);
121
205
  acl.push(control);
122
206
  } catch (e) {
123
- toast('error', e);
207
+ await toast('error', e);
124
208
  }
125
209
  }}
126
210
  sources={[discovery.user, discovery.role]}
@@ -131,6 +215,21 @@
131
215
  .includes(result.target)}
132
216
  placeholder={text('AccessControlDialog.placeholder')}
133
217
  />
218
+
219
+ {#if !acl.some(control => getTarget(control) === null)}
220
+ <div>
221
+ <button
222
+ class="icon-text"
223
+ onclick={() =>
224
+ addToACL(itemType, item.id, null)
225
+ .then(control => acl.push(control))
226
+ .catch(e => toast('error', e))}
227
+ >
228
+ <Icon i="globe" />
229
+ <span>{text('AccessControlDialog.add_public')}</span>
230
+ </button>
231
+ </div>
232
+ {/if}
134
233
  {/if}
135
234
 
136
235
  <div>
@@ -138,6 +237,36 @@
138
237
  </div>
139
238
  </dialog>
140
239
 
240
+ <FormDialog bind:dialog={customDialog} submitText={text('AccessControlDialog.save')} submit={() => update(customizing!, draft)}>
241
+ {#snippet header()}
242
+ <h3>{text('AccessControlDialog.custom_title')}</h3>
243
+ {/snippet}
244
+
245
+ <div class="permissions">
246
+ {#each Object.keys(draft) as name}
247
+ {const id = `${item.id}.custom.${name}`}
248
+ {const implied = $derived(isImplied(draft, name))}
249
+ <span class="icon-text">
250
+ <input
251
+ {id}
252
+ type="checkbox"
253
+ checked={draft[name]}
254
+ disabled={implied}
255
+ onchange={event => {
256
+ const { checked } = event.currentTarget;
257
+ if (config) Object.assign(draft, resolvePermissions(config, { [name]: checked }));
258
+ else draft[name] = checked;
259
+ }}
260
+ />
261
+ <label for={id} class={['checkbox', implied && 'disabled']}>
262
+ {#if draft[name]}<Icon i="check" --size="1.3em" />{/if}
263
+ </label>
264
+ <label for={id}>{permissionText(name)}</label>
265
+ </span>
266
+ {/each}
267
+ </div>
268
+ </FormDialog>
269
+
141
270
  <style>
142
271
  dialog:open {
143
272
  display: flex;
@@ -149,38 +278,34 @@
149
278
  float: right;
150
279
  }
151
280
 
152
- .permissions {
153
- display: flex;
154
- flex-direction: column;
155
- gap: 0.1em;
156
- }
281
+ .entries {
282
+ display: grid;
283
+ grid-template-columns: 1fr auto 2em;
157
284
 
158
- .actions {
159
- display: flex;
160
- gap: 1em;
161
- align-items: center;
285
+ @media (width > 700px) {
286
+ min-width: 30em;
287
+ }
162
288
  }
163
289
 
164
290
  .AccessControl {
165
291
  display: grid;
292
+ grid-column: 1 / -1;
293
+ grid-template-columns: subgrid;
294
+ align-items: center;
166
295
  gap: 1em;
167
- grid-template-columns: 1fr 1fr;
168
- padding: 1em 2em;
296
+ padding: 0.75em 1em;
169
297
  border-bottom: var(--border-accent);
298
+ }
170
299
 
171
- &.text {
172
- align-items: center;
173
- }
174
-
175
- .target {
176
- display: flex;
177
- flex-direction: column;
178
- justify-content: space-around;
179
- gap: 1em;
180
- }
300
+ .remove {
301
+ display: contents;
302
+ }
181
303
 
182
- @media (width > 700px) {
183
- min-width: 30em;
184
- }
304
+ .permissions {
305
+ display: flex;
306
+ flex-direction: column;
307
+ gap: 0.5em;
308
+ max-height: 60vh;
309
+ overflow-y: auto;
185
310
  }
186
311
  </style>
@@ -1,8 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { text } from '@axium/client/locales';
3
- import { fetchAPI } from '@axium/client/requests';
3
+ import { apps } from '@axium/core/apps';
4
4
  import feature from '@axium/core/features';
5
- import Boundary from './Boundary.svelte';
6
5
  import Icon from './Icon.svelte';
7
6
  import Popover from './Popover.svelte';
8
7
  </script>
@@ -14,24 +13,22 @@
14
13
  </button>
15
14
  {/snippet}
16
15
 
17
- <Boundary pending="generic.loading" error="AppMenu.failed" inline>
18
- <div class={['AppList', feature('app-list-is-grid') && 'grid']}>
19
- {#each await fetchAPI('GET', 'apps') as app}
20
- <a class="menu-item" href="/{app.id}">
21
- {#if app.image}
22
- <img src={app.image} alt={app.name} />
23
- {:else if app.icon}
24
- <Icon i={app.icon} --size="1.5em" />
25
- {:else}
26
- <Icon i="image-circle-xmark" --size="1.5em" />
27
- {/if}
28
- <span>{text('app_name.' + app.id, { $default: app.name || '(unknown)' })}</span>
29
- </a>
30
- {:else}
31
- <i>{text('AppMenu.none')}</i>
32
- {/each}
33
- </div>
34
- </Boundary>
16
+ <div class={['AppList', feature('app-list-is-grid') && 'grid']}>
17
+ {#each apps.values() as app}
18
+ <a class="menu-item" href="/{app.id}">
19
+ {#if app.image}
20
+ <img src={app.image} alt={app.name} />
21
+ {:else if app.icon}
22
+ <Icon i={app.icon} --size="1.5em" />
23
+ {:else}
24
+ <Icon i="image-circle-xmark" --size="1.5em" />
25
+ {/if}
26
+ <span>{text('app_name.' + app.id, { $default: app.name || '(unknown)' })}</span>
27
+ </a>
28
+ {:else}
29
+ <i>{text('AppMenu.none')}</i>
30
+ {/each}
31
+ </div>
35
32
  </Popover>
36
33
 
37
34
  <style>
@@ -0,0 +1,52 @@
1
+ <script lang="ts">
2
+ /** From 0 to 1. Without a finite number, the ring spins instead. */
3
+ const { value }: { value?: number | null } = $props();
4
+
5
+ const measured = $derived(typeof value == 'number' && Number.isFinite(value));
6
+ </script>
7
+
8
+ <svg
9
+ class={['ProgressRing', !measured && 'indeterminate']}
10
+ viewBox="0 0 20 20"
11
+ role="progressbar"
12
+ aria-valuenow={measured ? Math.round(value! * 100) : undefined}
13
+ aria-valuemin={0}
14
+ aria-valuemax={100}
15
+ >
16
+ <circle class="track" cx="10" cy="10" r="8" />
17
+ <circle class="fill" cx="10" cy="10" r="8" pathLength="100" stroke-dasharray="{measured ? value! * 100 : 25} 100" />
18
+ </svg>
19
+
20
+ <style>
21
+ .ProgressRing {
22
+ width: var(--size, 1em);
23
+ height: var(--size, 1em);
24
+ flex-shrink: 0;
25
+ rotate: -90deg;
26
+ }
27
+
28
+ circle {
29
+ fill: none;
30
+ stroke-width: 3;
31
+ }
32
+
33
+ .track {
34
+ stroke: var(--bg-strong);
35
+ }
36
+
37
+ .fill {
38
+ stroke: var(--fg-accent);
39
+ stroke-linecap: round;
40
+ transition: stroke-dasharray 0.5s;
41
+ }
42
+
43
+ .indeterminate {
44
+ animation: spin 1s linear infinite;
45
+ }
46
+
47
+ @keyframes spin {
48
+ to {
49
+ rotate: 270deg;
50
+ }
51
+ }
52
+ </style>
package/lib/index.ts CHANGED
@@ -18,6 +18,7 @@ export { default as Logout } from './Logout.svelte';
18
18
  export { default as MediaControls } from './MediaControls.svelte';
19
19
  export { default as NumberBar } from './NumberBar.svelte';
20
20
  export { default as Popover } from './Popover.svelte';
21
+ export { default as ProgressRing } from './ProgressRing.svelte';
21
22
  export { default as PWAIndicator } from './PWAIndicator.svelte';
22
23
  export { default as Register } from './Register.svelte';
23
24
  export { default as SessionList } from './SessionList.svelte';
package/locales/en.json CHANGED
@@ -7,11 +7,15 @@
7
7
  "toast_removed": "Removed access",
8
8
  "public_target": "Everyone",
9
9
  "add_public": "Add Public Access",
10
- "placeholder": "Add users and roles"
10
+ "placeholder": "Add users and roles",
11
+ "no_access": "No access",
12
+ "remove_self_confirm": "Remove your own access? You won't be able to open this or change who it's shared with.",
13
+ "customize": "Custom…",
14
+ "custom_title": "Custom permissions",
15
+ "save": "Save"
11
16
  },
12
17
  "AppMenu": {
13
18
  "label": "Apps",
14
- "failed": "Couldn't load apps.",
15
19
  "none": "No apps available."
16
20
  },
17
21
  "AppPreferences": {
@@ -105,6 +109,7 @@
105
109
  "account": {
106
110
  "delete_account": "Delete Account",
107
111
  "delete_account_confirm": "Are you sure you want to delete your account?",
112
+ "device_preferences": "On this device",
108
113
  "edit_email": "Email Address",
109
114
  "edit_name": "What do you want to be called?",
110
115
  "edit_username": "Pick a unique username",
@@ -113,7 +118,12 @@
113
118
  "load_failed": {
114
119
  "passkeys": "Couldn't load your passkeys",
115
120
  "recovery": "Couldn't load your recovery options",
116
- "sessions": "Couldn't load your sessions"
121
+ "sessions": "Couldn't load your sessions",
122
+ "device_preferences": "Couldn't load this device's preferences"
123
+ },
124
+ "notifications": {
125
+ "blocked": "Notifications are blocked in your browser's site settings",
126
+ "label": "Notifications"
117
127
  },
118
128
  "passkeys": {
119
129
  "backed_up": "This passkey is backed up",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/client",
3
- "version": "0.40.2",
3
+ "version": "0.42.0",
4
4
  "author": "James Prevett <jp@jamespre.dev>",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -50,7 +50,7 @@
50
50
  "build": "tsc"
51
51
  },
52
52
  "peerDependencies": {
53
- "@axium/core": ">=0.41.3",
53
+ "@axium/core": ">=0.43.0",
54
54
  "@james-pre/locales": "^1.0.0",
55
55
  "ioium": "^1.7.0",
56
56
  "semver": "^7.7.4",