@shellui/core 0.5.3 → 0.6.0-beta.1

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.
Files changed (113) hide show
  1. package/README.md +2 -0
  2. package/package.json +6 -4
  3. package/schemas/shellui.config.schema.json +104 -64
  4. package/src/app.tsx +5 -3
  5. package/src/components/ContentView.tsx +14 -23
  6. package/src/components/LoadingOverlay.tsx +1 -1
  7. package/src/components/ui/sonner.spec.tsx +138 -0
  8. package/src/components/ui/sonner.tsx +5 -5
  9. package/src/components/ui/switch.tsx +1 -1
  10. package/src/features/admin/AdminView.tsx +14 -3
  11. package/src/features/ai/AiBridge.tsx +106 -0
  12. package/src/features/ai/AiUnavailableResponder.tsx +39 -0
  13. package/src/features/ai/README.md +52 -0
  14. package/src/features/ai/ShellAiHost.tsx +24 -0
  15. package/src/features/ai/adapters/ollama.ts +170 -0
  16. package/src/features/ai/adapters/promptApi.spec.ts +135 -0
  17. package/src/features/ai/adapters/promptApi.ts +222 -0
  18. package/src/features/ai/adapters/webllm.experimental.spec.ts +69 -0
  19. package/src/features/ai/adapters/webllm.spec.ts +527 -0
  20. package/src/features/ai/adapters/webllm.ts +142 -0
  21. package/src/features/ai/aiDisabledResponses.spec.ts +29 -0
  22. package/src/features/ai/aiDisabledResponses.ts +32 -0
  23. package/src/features/ai/browserInstallStore.spec.ts +58 -0
  24. package/src/features/ai/browserInstallStore.ts +76 -0
  25. package/src/features/ai/catalog.ts +31 -0
  26. package/src/features/ai/createRegistry.ts +83 -0
  27. package/src/features/ai/developHarness.spec.ts +108 -0
  28. package/src/features/ai/developHarness.ts +161 -0
  29. package/src/features/ai/engine/formatAiError.spec.ts +85 -0
  30. package/src/features/ai/engine/formatAiError.ts +132 -0
  31. package/src/features/ai/engine/mapInitProgress.ts +9 -0
  32. package/src/features/ai/engine/normalizeWebLlmModule.spec.ts +47 -0
  33. package/src/features/ai/engine/vite-worker.d.ts +6 -0
  34. package/src/features/ai/engine/webllm.worker.ts +51 -0
  35. package/src/features/ai/engine/webllmEngine.ts +1011 -0
  36. package/src/features/ai/handleRequest.spec.ts +288 -0
  37. package/src/features/ai/handleRequest.ts +325 -0
  38. package/src/features/ai/isAiFeatureEnabled.spec.ts +15 -0
  39. package/src/features/ai/isAiFeatureEnabled.ts +9 -0
  40. package/src/features/ai/promptApiSupport.spec.ts +64 -0
  41. package/src/features/ai/promptApiSupport.ts +117 -0
  42. package/src/features/ai/registry.spec.ts +100 -0
  43. package/src/features/ai/registry.ts +131 -0
  44. package/src/features/ai/status.spec.ts +92 -0
  45. package/src/features/ai/status.ts +85 -0
  46. package/src/features/ai/types.ts +100 -0
  47. package/src/features/ai/webLlmBrowserSupport.spec.ts +86 -0
  48. package/src/features/ai/webLlmBrowserSupport.ts +92 -0
  49. package/src/features/alertDialog/DialogContext.tsx +3 -1
  50. package/src/features/auth/AuthProvider.tsx +254 -39
  51. package/src/features/auth/backends/index.ts +8 -0
  52. package/src/features/auth/backends/shellui.spec.ts +201 -0
  53. package/src/features/auth/backends/shellui.ts +93 -16
  54. package/src/features/auth/backends/supabase.ts +8 -0
  55. package/src/features/auth/backends/types.ts +16 -1
  56. package/src/features/auth/components/LoginButton.tsx +26 -2
  57. package/src/features/auth/components/LoginView.tsx +114 -133
  58. package/src/features/auth/components/SessionLoadingView.tsx +21 -0
  59. package/src/features/auth/hooks/useAuth.tsx +12 -0
  60. package/src/features/auth/shellAccountRequests.ts +76 -0
  61. package/src/features/auth/utils/authRequestError.ts +4 -1
  62. package/src/features/auth/utils/authSessionPersistence.spec.ts +11 -0
  63. package/src/features/auth/utils/authSessionPersistence.ts +12 -0
  64. package/src/features/auth/utils/index.ts +4 -0
  65. package/src/features/auth/utils/resolveLoginSettings.spec.ts +33 -0
  66. package/src/features/auth/utils/resolveLoginSettings.ts +33 -0
  67. package/src/features/auth/utils/shareInFlight.spec.ts +41 -0
  68. package/src/features/auth/utils/shareInFlight.ts +14 -0
  69. package/src/features/config/ConfigProvider.ts +9 -1
  70. package/src/features/config/types.ts +43 -0
  71. package/src/features/layouts/appbar/AppBarLayout.tsx +8 -3
  72. package/src/features/layouts/filterNavigationForAuthState.spec.ts +41 -0
  73. package/src/features/layouts/floating/FloatingLayout.tsx +9 -4
  74. package/src/features/layouts/floating/layoutChromeStore.ts +3 -1
  75. package/src/features/layouts/sidebar/SidebarLayout.tsx +9 -4
  76. package/src/features/layouts/utils.ts +6 -2
  77. package/src/features/layouts/windows/WindowsLayout.tsx +8 -3
  78. package/src/features/messaging/MessagingSecurityBootstrap.tsx +6 -6
  79. package/src/features/security/trustedFrames.spec.ts +65 -0
  80. package/src/features/security/trustedFrames.ts +52 -0
  81. package/src/features/settings/SettingsIcons.tsx +17 -0
  82. package/src/features/settings/SettingsProvider.tsx +29 -4
  83. package/src/features/settings/SettingsRoutes.tsx +8 -0
  84. package/src/features/settings/SettingsView.tsx +21 -4
  85. package/src/features/settings/components/Ai.tsx +830 -0
  86. package/src/features/settings/components/Develop.tsx +4 -0
  87. package/src/features/settings/components/Storage.tsx +197 -32
  88. package/src/features/settings/components/UserSettingsPanel.tsx +160 -12
  89. package/src/features/settings/components/createUserSettingsRoute.tsx +4 -0
  90. package/src/features/settings/components/develop/AiTestTools.tsx +231 -0
  91. package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +54 -1
  92. package/src/features/settings/utils/buildSettingsForPropagation.ts +15 -1
  93. package/src/features/settings/utils/mergePreferencesIntoSettings.spec.ts +6 -0
  94. package/src/features/settings/utils/shouldShowStorageSettings.spec.ts +49 -0
  95. package/src/features/settings/utils/shouldShowStorageSettings.ts +19 -0
  96. package/src/features/storage/uploads/UploadToastCard.tsx +2 -442
  97. package/src/features/storage/uploads/UploadToaster.tsx +2 -44
  98. package/src/features/storage/uploads/uploadQueue.ts +128 -308
  99. package/src/features/storage/uploads/useUploadQueue.ts +7 -3
  100. package/src/features/transfers/TransferToastCard.tsx +467 -0
  101. package/src/features/transfers/TransferToaster.tsx +50 -0
  102. package/src/features/transfers/index.ts +33 -0
  103. package/src/features/transfers/transferQueue.spec.ts +97 -0
  104. package/src/features/transfers/transferQueue.ts +442 -0
  105. package/src/features/transfers/types.ts +38 -0
  106. package/src/features/transfers/useTransferQueue.ts +30 -0
  107. package/src/i18n/translations/en/common.json +46 -2
  108. package/src/i18n/translations/en/settings.json +151 -2
  109. package/src/i18n/translations/fr/common.json +46 -2
  110. package/src/i18n/translations/fr/settings.json +151 -2
  111. package/src/index.css +57 -4
  112. package/src/index.ts +1 -0
  113. package/src/routes/components/NavigationItemRoute.tsx +2 -1
@@ -1,442 +1,2 @@
1
- import type { ReactNode } from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import { Button } from '../../../components/ui/button';
4
- import {
5
- Tooltip,
6
- TooltipContent,
7
- TooltipProvider,
8
- TooltipTrigger,
9
- } from '../../../components/ui/tooltip';
10
- import { cn } from '../../../lib/utils';
11
- import { formatBytes } from '../quota';
12
- import type { UploadItem } from './types';
13
- import {
14
- closeUploadToaster,
15
- getItemPercent,
16
- interruptAllUploads,
17
- interruptUpload,
18
- removeUpload,
19
- setUploadToastExpanded,
20
- } from './uploadQueue';
21
- import { useUploadQueue } from './useUploadQueue';
22
-
23
- function ChevronIcon({ expanded }: { expanded: boolean }) {
24
- return (
25
- <svg
26
- xmlns="http://www.w3.org/2000/svg"
27
- width="16"
28
- height="16"
29
- viewBox="0 0 24 24"
30
- fill="none"
31
- stroke="currentColor"
32
- strokeWidth="2"
33
- strokeLinecap="round"
34
- strokeLinejoin="round"
35
- className={cn('transition-transform duration-200', expanded ? 'rotate-0' : 'rotate-180')}
36
- >
37
- <path d="m6 9 6 6 6-6" />
38
- </svg>
39
- );
40
- }
41
-
42
- function CloseIcon() {
43
- return (
44
- <svg
45
- xmlns="http://www.w3.org/2000/svg"
46
- width="16"
47
- height="16"
48
- viewBox="0 0 24 24"
49
- fill="none"
50
- stroke="currentColor"
51
- strokeWidth="2"
52
- strokeLinecap="round"
53
- strokeLinejoin="round"
54
- >
55
- <path d="M18 6 6 18" />
56
- <path d="m6 6 12 12" />
57
- </svg>
58
- );
59
- }
60
-
61
- function CheckIcon() {
62
- return (
63
- <svg
64
- xmlns="http://www.w3.org/2000/svg"
65
- width="14"
66
- height="14"
67
- viewBox="0 0 24 24"
68
- fill="none"
69
- stroke="currentColor"
70
- strokeWidth="2.5"
71
- strokeLinecap="round"
72
- strokeLinejoin="round"
73
- >
74
- <path d="M20 6 9 17l-5-5" />
75
- </svg>
76
- );
77
- }
78
-
79
- function AlertIcon() {
80
- return (
81
- <svg
82
- xmlns="http://www.w3.org/2000/svg"
83
- width="14"
84
- height="14"
85
- viewBox="0 0 24 24"
86
- fill="none"
87
- stroke="currentColor"
88
- strokeWidth="2"
89
- strokeLinecap="round"
90
- strokeLinejoin="round"
91
- >
92
- <circle
93
- cx="12"
94
- cy="12"
95
- r="10"
96
- />
97
- <line
98
- x1="12"
99
- x2="12"
100
- y1="8"
101
- y2="12"
102
- />
103
- <line
104
- x1="12"
105
- x2="12.01"
106
- y1="16"
107
- y2="16"
108
- />
109
- </svg>
110
- );
111
- }
112
-
113
- function CircularProgress({
114
- percent,
115
- tone,
116
- }: {
117
- percent: number;
118
- tone: 'primary' | 'destructive' | 'muted';
119
- }) {
120
- const radius = 10;
121
- const circumference = 2 * Math.PI * radius;
122
- const offset = circumference - (percent / 100) * circumference;
123
- const stroke =
124
- tone === 'destructive'
125
- ? 'stroke-destructive'
126
- : tone === 'muted'
127
- ? 'stroke-muted-foreground'
128
- : 'stroke-primary';
129
-
130
- return (
131
- <svg
132
- className="size-8 -rotate-90"
133
- viewBox="0 0 24 24"
134
- aria-hidden
135
- >
136
- <circle
137
- cx="12"
138
- cy="12"
139
- r={radius}
140
- fill="none"
141
- className="stroke-muted"
142
- strokeWidth="2.5"
143
- />
144
- <circle
145
- cx="12"
146
- cy="12"
147
- r={radius}
148
- fill="none"
149
- className={stroke}
150
- strokeWidth="2.5"
151
- strokeLinecap="round"
152
- strokeDasharray={circumference}
153
- strokeDashoffset={offset}
154
- style={{ transition: 'stroke-dashoffset 160ms ease-out' }}
155
- />
156
- </svg>
157
- );
158
- }
159
-
160
- function StatusGlyph({
161
- uploading,
162
- error,
163
- percent,
164
- }: {
165
- uploading: boolean;
166
- error: boolean;
167
- percent: number;
168
- }) {
169
- if (uploading) {
170
- return (
171
- <CircularProgress
172
- percent={percent}
173
- tone="primary"
174
- />
175
- );
176
- }
177
- if (error) {
178
- return (
179
- <div className="flex size-8 items-center justify-center rounded-full bg-destructive/10 text-destructive">
180
- <AlertIcon />
181
- </div>
182
- );
183
- }
184
- return (
185
- <div className="flex size-8 items-center justify-center rounded-full bg-primary/10 text-primary">
186
- <CheckIcon />
187
- </div>
188
- );
189
- }
190
-
191
- function ProgressTrack({
192
- percent,
193
- tone = 'primary',
194
- }: {
195
- percent: number;
196
- tone?: 'primary' | 'destructive';
197
- }) {
198
- return (
199
- <div
200
- className="h-1.5 w-full overflow-hidden rounded-full bg-muted"
201
- role="progressbar"
202
- aria-valuemin={0}
203
- aria-valuemax={100}
204
- aria-valuenow={percent}
205
- >
206
- <div
207
- className={cn(
208
- 'h-full rounded-full transition-[width] duration-200 ease-out',
209
- tone === 'destructive' ? 'bg-destructive' : 'bg-primary',
210
- )}
211
- style={{ width: `${percent}%` }}
212
- />
213
- </div>
214
- );
215
- }
216
-
217
- function IconButton({
218
- label,
219
- onClick,
220
- children,
221
- }: {
222
- label: string;
223
- onClick: () => void;
224
- children: ReactNode;
225
- }) {
226
- return (
227
- <Tooltip>
228
- <TooltipTrigger asChild>
229
- <Button
230
- type="button"
231
- variant="ghost"
232
- size="icon"
233
- data-upload-action=""
234
- aria-label={label}
235
- className="size-7 shrink-0 text-muted-foreground hover:text-foreground [touch-action:manipulation]"
236
- onClick={(event) => {
237
- event.stopPropagation();
238
- onClick();
239
- }}
240
- >
241
- {children}
242
- </Button>
243
- </TooltipTrigger>
244
- <TooltipContent
245
- side="top"
246
- align="center"
247
- collisionPadding={12}
248
- >
249
- {label}
250
- </TooltipContent>
251
- </Tooltip>
252
- );
253
- }
254
-
255
- function titleForSummary(
256
- t: (key: string, options?: Record<string, unknown>) => string,
257
- summary: ReturnType<typeof useUploadQueue>['summary'],
258
- ): string {
259
- if (summary.uploading > 0) {
260
- return t('uploads.titleUploading', { count: summary.uploading });
261
- }
262
- if (summary.error > 0 && summary.success > 0) {
263
- return t('uploads.titleMixed', { success: summary.success, errors: summary.error });
264
- }
265
- if (summary.error > 0) {
266
- return t('uploads.titleFailed', { count: summary.error });
267
- }
268
- if (summary.success > 0) {
269
- return t('uploads.titleComplete', { count: summary.success });
270
- }
271
- if (summary.cancelled > 0) {
272
- return t('uploads.titleCancelled', { count: summary.cancelled });
273
- }
274
- return t('uploads.titleCancelled', { count: summary.total });
275
- }
276
-
277
- function FileRow({ item, locale }: { item: UploadItem; locale: string }) {
278
- const { t } = useTranslation('common');
279
- const percent = getItemPercent(item);
280
- const isUploading = item.status === 'uploading';
281
- const sizeLabel = item.size > 0 ? formatBytes(item.size, locale) : null;
282
-
283
- return (
284
- <div className="flex flex-col gap-1.5 py-2">
285
- <div className="flex items-start gap-2">
286
- <div className="min-w-0 flex-1">
287
- <p
288
- className={cn(
289
- 'truncate text-sm font-medium leading-tight',
290
- item.status === 'cancelled' && 'text-muted-foreground',
291
- )}
292
- >
293
- {item.name}
294
- </p>
295
- <p
296
- className={cn(
297
- 'mt-0.5 text-xs',
298
- item.status === 'error' ? 'text-destructive' : 'text-muted-foreground',
299
- )}
300
- >
301
- {item.status === 'error'
302
- ? item.error || t('uploads.statusError')
303
- : isUploading
304
- ? [sizeLabel, t('uploads.progressPercent', { percent })].filter(Boolean).join(' · ')
305
- : item.status === 'success'
306
- ? [sizeLabel, t('uploads.statusComplete')].filter(Boolean).join(' · ')
307
- : t('uploads.statusCancelled')}
308
- </p>
309
- </div>
310
- <IconButton
311
- label={isUploading ? t('uploads.cancelFile') : t('uploads.removeFile')}
312
- onClick={() => (isUploading ? interruptUpload(item.id) : removeUpload(item.id))}
313
- >
314
- <CloseIcon />
315
- </IconButton>
316
- </div>
317
- {isUploading ? <ProgressTrack percent={percent} /> : null}
318
- </div>
319
- );
320
- }
321
-
322
- export function UploadToastCard() {
323
- const { t, i18n } = useTranslation('common');
324
- const { items, summary, expanded } = useUploadQueue();
325
- const locale = i18n.language || 'en';
326
- const title = titleForSummary(t, summary);
327
- const hasErrors = summary.error > 0;
328
- const subtitleParts: string[] = [];
329
-
330
- if (summary.uploading > 0 && summary.bytesTotal > 0) {
331
- subtitleParts.push(
332
- t('uploads.bytesProgress', {
333
- uploaded: formatBytes(summary.bytesUploaded, locale),
334
- total: formatBytes(summary.bytesTotal, locale),
335
- }),
336
- );
337
- }
338
- if (hasErrors) {
339
- subtitleParts.push(t('uploads.errorCount', { count: summary.error }));
340
- }
341
- if (summary.cancelled > 0) {
342
- subtitleParts.push(t('uploads.cancelledCount', { count: summary.cancelled }));
343
- }
344
- if (summary.uploading > 0 && summary.total > summary.uploading) {
345
- subtitleParts.push(
346
- t('uploads.filesProgress', { done: summary.success + summary.error, total: summary.total }),
347
- );
348
- }
349
-
350
- return (
351
- <TooltipProvider delayDuration={200}>
352
- <div
353
- className="w-[min(24rem,calc(100vw-1.5rem))] overflow-hidden rounded-xl border border-border bg-background text-foreground shadow-lg"
354
- data-upload-toast=""
355
- role="status"
356
- aria-live="polite"
357
- aria-busy={summary.uploading > 0}
358
- >
359
- <div className="flex items-start gap-3 p-3">
360
- <StatusGlyph
361
- uploading={summary.uploading > 0}
362
- error={hasErrors && summary.uploading === 0}
363
- percent={summary.percent}
364
- />
365
- <button
366
- type="button"
367
- className="min-w-0 flex-1 cursor-pointer text-left [touch-action:manipulation]"
368
- aria-expanded={expanded}
369
- aria-label={expanded ? t('uploads.collapse') : t('uploads.expand')}
370
- onClick={() => setUploadToastExpanded(!expanded)}
371
- >
372
- <p
373
- className="truncate text-sm font-medium leading-tight"
374
- style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
375
- >
376
- {title}
377
- </p>
378
- {subtitleParts.length > 0 ? (
379
- <p className="mt-0.5 truncate text-xs text-muted-foreground">
380
- {subtitleParts.join(' · ')}
381
- </p>
382
- ) : null}
383
- </button>
384
- <div className="flex items-center">
385
- <IconButton
386
- label={expanded ? t('uploads.collapse') : t('uploads.expand')}
387
- onClick={() => setUploadToastExpanded(!expanded)}
388
- >
389
- <ChevronIcon expanded={expanded} />
390
- </IconButton>
391
- <IconButton
392
- label={summary.uploading > 0 ? t('uploads.closeAndCancel') : t('uploads.dismiss')}
393
- onClick={() => closeUploadToaster()}
394
- >
395
- <CloseIcon />
396
- </IconButton>
397
- </div>
398
- </div>
399
- <div className="px-3 pb-3">
400
- <ProgressTrack
401
- percent={summary.percent}
402
- tone={hasErrors && summary.uploading === 0 ? 'destructive' : 'primary'}
403
- />
404
- </div>
405
- <div
406
- className={cn(
407
- 'grid transition-[grid-template-rows] duration-300 ease-out',
408
- expanded ? 'grid-rows-[1fr]' : 'grid-rows-[0fr]',
409
- )}
410
- >
411
- <div className="overflow-hidden">
412
- <div className="border-t border-border px-3">
413
- <div className="max-h-[min(14rem,calc(var(--shellui-app-height,100dvh)-14rem))] overflow-y-auto overscroll-contain divide-y divide-border">
414
- {items.map((item) => (
415
- <FileRow
416
- key={item.id}
417
- item={item}
418
- locale={locale}
419
- />
420
- ))}
421
- </div>
422
- {summary.uploading > 0 ? (
423
- <div className="flex justify-end py-2">
424
- <Button
425
- type="button"
426
- variant="ghost"
427
- size="sm"
428
- data-upload-action=""
429
- className="h-8 text-xs text-muted-foreground [touch-action:manipulation]"
430
- onClick={() => interruptAllUploads()}
431
- >
432
- {t('uploads.cancelAll')}
433
- </Button>
434
- </div>
435
- ) : null}
436
- </div>
437
- </div>
438
- </div>
439
- </div>
440
- </TooltipProvider>
441
- );
442
- }
1
+ /** Re-export shared transfer toast card under the historical upload name. */
2
+ export { TransferToastCard as UploadToastCard } from '../../transfers/TransferToastCard.js';
@@ -1,44 +1,2 @@
1
- import { useEffect } from 'react';
2
- import { createPortal } from 'react-dom';
3
- import { shellui } from '@shellui/sdk';
4
- import { UploadToastCard } from './UploadToastCard';
5
- import { startUploadToastDemo, UPLOAD_TOAST_DEMO_MESSAGE, UPLOAD_TOAST_ID } from './uploadQueue';
6
- import { useUploadQueue } from './useUploadQueue';
7
- import { Z_INDEX } from '../../../lib/z-index';
8
-
9
- function isShellUiRoot(): boolean {
10
- return typeof window !== 'undefined' && window.parent === window;
11
- }
12
-
13
- /**
14
- * Custom upload toast at the outermost Shellui window. Nested iframes never
15
- * render it — they post uploads / demo requests up so the root can show this
16
- * panel above modals and keep it while the user navigates.
17
- */
18
- export function UploadToaster() {
19
- const isRoot = isShellUiRoot();
20
- const { items } = useUploadQueue();
21
-
22
- useEffect(() => {
23
- if (!isRoot) return;
24
- return shellui.addMessageListener(UPLOAD_TOAST_DEMO_MESSAGE, () => {
25
- startUploadToastDemo();
26
- });
27
- }, [isRoot]);
28
-
29
- if (!isRoot || items.length === 0) return null;
30
-
31
- // Portal to body so z-index sits above portaled modals/drawers (same as Sonner).
32
- return createPortal(
33
- <div
34
- id={UPLOAD_TOAST_ID}
35
- className="pointer-events-none fixed right-[max(0.75rem,env(safe-area-inset-right,0px))] bottom-[max(5rem,calc(5rem+env(safe-area-inset-bottom,0px)))] md:right-[max(1rem,env(safe-area-inset-right,0px))] md:bottom-[max(1rem,env(safe-area-inset-bottom,0px))]"
36
- style={{ zIndex: Z_INDEX.TOAST }}
37
- >
38
- <div className="pointer-events-auto origin-bottom animate-in fade-in-0 slide-in-from-bottom-2 duration-200">
39
- <UploadToastCard />
40
- </div>
41
- </div>,
42
- document.body,
43
- );
44
- }
1
+ /** Re-export shared transfer toaster under the historical upload name. */
2
+ export { TransferToaster as UploadToaster } from '../../transfers/TransferToaster.js';