@shellui/core 0.7.0-alpha.9 → 0.7.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.
- package/README.md +1 -1
- package/package.json +23 -6
- package/src/components/ui/drawer.tsx +47 -30
- package/src/components/ui/sheet.tsx +18 -12
- package/src/components/ui/shell-divider.spec.tsx +63 -0
- package/src/components/ui/shell-divider.tsx +20 -0
- package/src/components/ui/sidebar.tsx +26 -12
- package/src/components/ui/tooltip.tsx +4 -2
- package/src/features/admin/AdminView.tsx +9 -6
- package/src/features/auth/components/LoginButton.spec.tsx +203 -0
- package/src/features/auth/components/LoginButton.tsx +77 -28
- package/src/features/auth/components/LoginButtonIcons.tsx +4 -8
- package/src/features/chromeActions/ChromeActionsHost.tsx +5 -1
- package/src/features/chromeActions/computeActionInsets.ts +7 -4
- package/src/features/layouts/OverlayShell.tsx +58 -40
- package/src/features/layouts/appbar/AppBarItemIcon.spec.tsx +45 -0
- package/src/features/layouts/appbar/AppBarItemIcon.tsx +19 -0
- package/src/features/layouts/appbar/AppBarLayout.tsx +115 -110
- package/src/features/layouts/appbar/appBarOverflow.spec.ts +27 -0
- package/src/features/layouts/appbar/appBarOverflow.ts +42 -0
- package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +13 -24
- package/src/features/layouts/chrome/ContentDragOverlay.tsx +5 -6
- package/src/features/layouts/chrome/DesktopChrome.tsx +37 -0
- package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +15 -4
- package/src/features/layouts/chrome/MacStrip.tsx +33 -0
- package/src/features/layouts/chrome/constants.ts +36 -8
- package/src/features/layouts/chrome/index.ts +8 -0
- package/src/features/layouts/chrome/stripDragMap.ts +35 -0
- package/src/features/layouts/chrome/stripNoDrag.spec.tsx +103 -0
- package/src/features/layouts/chrome/useScrollHideChrome.ts +3 -8
- package/src/features/layouts/chrome/viewport.ts +11 -4
- package/src/features/layouts/floating/FloatingBottomDock.tsx +263 -43
- package/src/features/layouts/floating/FloatingLayout.tsx +14 -8
- package/src/features/layouts/floating/FloatingSidebar.tsx +178 -81
- package/src/features/layouts/floating/computeFloatingInsets.ts +22 -4
- package/src/features/layouts/floating/moreSections.spec.ts +28 -0
- package/src/features/layouts/floating/moreSections.ts +31 -0
- package/src/features/layouts/floating/useFloatingChrome.ts +3 -1
- package/src/features/layouts/floating/useSoftKeyboard.spec.ts +39 -0
- package/src/features/layouts/floating/useSoftKeyboard.ts +82 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.spec.tsx +68 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.tsx +47 -10
- package/src/features/layouts/sidebar/NavigationContent.tsx +17 -9
- package/src/features/layouts/sidebar/SidebarIcons.tsx +70 -9
- package/src/features/layouts/sidebar/SidebarInner.spec.tsx +149 -0
- package/src/features/layouts/sidebar/SidebarInner.tsx +103 -43
- package/src/features/layouts/sidebar/SidebarLayout.tsx +24 -17
- package/src/features/layouts/windows/DesktopDots.tsx +76 -0
- package/src/features/layouts/windows/WindowsLayout.tsx +265 -160
- package/src/features/layouts/windows/deskDots.spec.ts +54 -0
- package/src/features/layouts/windows/deskDots.ts +314 -0
- package/src/features/overlays/ResponsiveModal.tsx +5 -3
- package/src/features/overlays/overlaySize.spec.ts +56 -16
- package/src/features/overlays/overlaySize.ts +114 -31
- package/src/features/overlays/phoneDrawerAnchoring.spec.ts +187 -0
- package/src/features/overlays/useOverlayReportedSize.ts +8 -3
- package/src/features/theme/applyTheme.ts +8 -0
- package/src/features/theme/navContrast.spec.ts +49 -0
- package/src/features/theme/navContrast.ts +108 -0
- package/src/i18n/translations/en/common.json +26 -0
- package/src/i18n/translations/fr/common.json +26 -0
- package/src/index.css +1156 -77
- package/src/service-worker/devCaches.spec.ts +32 -0
- package/src/service-worker/devCaches.ts +27 -0
- package/src/service-worker/sw-dev.ts +23 -23
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { devCacheNames, isStaleDevCache } from './devCaches';
|
|
3
|
+
|
|
4
|
+
describe('dev service worker caches', () => {
|
|
5
|
+
it('names image, font and html caches after the core version', () => {
|
|
6
|
+
expect(devCacheNames('1.2.3')).toEqual({
|
|
7
|
+
images: 'shellui-dev-images-1.2.3',
|
|
8
|
+
fonts: 'shellui-dev-fonts-1.2.3',
|
|
9
|
+
html: 'shellui-dev-html-1.2.3',
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('has no cache for scripts or styles', () => {
|
|
14
|
+
expect(Object.keys(devCacheNames('1.2.3'))).not.toContain('static-resources');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('drops unversioned caches and caches from another version', () => {
|
|
18
|
+
for (const name of ['images', 'html-cache', 'static-resources', 'fonts']) {
|
|
19
|
+
expect(isStaleDevCache(name, '1.2.3')).toBe(true);
|
|
20
|
+
}
|
|
21
|
+
expect(isStaleDevCache('shellui-dev-images-1.2.2', '1.2.3')).toBe(true);
|
|
22
|
+
expect(isStaleDevCache('shellui-dev-static-1.2.3', '1.2.3')).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('keeps current caches and caches it does not own', () => {
|
|
26
|
+
for (const name of Object.values(devCacheNames('1.2.3'))) {
|
|
27
|
+
expect(isStaleDevCache(name, '1.2.3')).toBe(false);
|
|
28
|
+
}
|
|
29
|
+
expect(isStaleDevCache('workbox-precache-v2-http://localhost/', '1.2.3')).toBe(false);
|
|
30
|
+
expect(isStaleDevCache('api-cache', '1.2.3')).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache names for the dev service worker (`shellui start`).
|
|
3
|
+
*
|
|
4
|
+
* Vite serves the shell at the same URLs in every version (`/index.css`,
|
|
5
|
+
* `/main.tsx`, `/features/...`), so the dev worker never caches scripts or
|
|
6
|
+
* styles. Images, fonts and the offline HTML fallback use caches named after
|
|
7
|
+
* the core version, so an upgrade drops the previous ones.
|
|
8
|
+
*/
|
|
9
|
+
const DEV_CACHE_PREFIX = 'shellui-dev-';
|
|
10
|
+
|
|
11
|
+
/** Unversioned names written by older dev workers. */
|
|
12
|
+
const LEGACY_DEV_CACHES = ['images', 'html-cache', 'static-resources', 'fonts'];
|
|
13
|
+
|
|
14
|
+
export function devCacheNames(version: string) {
|
|
15
|
+
return {
|
|
16
|
+
images: `${DEV_CACHE_PREFIX}images-${version}`,
|
|
17
|
+
fonts: `${DEV_CACHE_PREFIX}fonts-${version}`,
|
|
18
|
+
html: `${DEV_CACHE_PREFIX}html-${version}`,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** True for a cache an older dev worker left behind. */
|
|
23
|
+
export function isStaleDevCache(name: string, version: string): boolean {
|
|
24
|
+
if (LEGACY_DEV_CACHES.includes(name)) return true;
|
|
25
|
+
if (!name.startsWith(DEV_CACHE_PREFIX)) return false;
|
|
26
|
+
return !Object.values(devCacheNames(version)).includes(name);
|
|
27
|
+
}
|
|
@@ -2,26 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
import { cleanupOutdatedCaches } from 'workbox-precaching';
|
|
4
4
|
import { registerRoute } from 'workbox-routing';
|
|
5
|
-
import { CacheFirst, NetworkFirst
|
|
5
|
+
import { CacheFirst, NetworkFirst } from 'workbox-strategies';
|
|
6
6
|
import { CacheableResponsePlugin } from 'workbox-cacheable-response';
|
|
7
7
|
import { ExpirationPlugin } from 'workbox-expiration';
|
|
8
8
|
import { getLogger } from '@shellui/sdk';
|
|
9
|
+
import { version as coreVersion } from '../../package.json';
|
|
10
|
+
import { devCacheNames, isStaleDevCache } from './devCaches';
|
|
9
11
|
|
|
10
12
|
const _logger = getLogger('shellcore');
|
|
11
13
|
|
|
12
14
|
declare const self: ServiceWorkerGlobalScope;
|
|
13
15
|
|
|
16
|
+
const CACHE = devCacheNames(coreVersion);
|
|
17
|
+
|
|
14
18
|
// Clean up old caches
|
|
15
19
|
cleanupOutdatedCaches();
|
|
16
20
|
|
|
17
|
-
// In dev mode, we don't precache (no manifest available)
|
|
18
|
-
//
|
|
21
|
+
// In dev mode, we don't precache (no manifest available).
|
|
22
|
+
// Scripts, styles and workers always come from the dev server: Vite serves them at
|
|
23
|
+
// the same URLs in every version, so a cached copy would show an older shell.
|
|
19
24
|
|
|
20
25
|
// Cache images with CacheFirst strategy
|
|
21
26
|
registerRoute(
|
|
22
27
|
({ request }) => request.destination === 'image',
|
|
23
28
|
new CacheFirst({
|
|
24
|
-
cacheName:
|
|
29
|
+
cacheName: CACHE.images,
|
|
25
30
|
plugins: [
|
|
26
31
|
new CacheableResponsePlugin({
|
|
27
32
|
statuses: [0, 200],
|
|
@@ -38,23 +43,7 @@ registerRoute(
|
|
|
38
43
|
registerRoute(
|
|
39
44
|
({ request }) => request.destination === 'document',
|
|
40
45
|
new NetworkFirst({
|
|
41
|
-
cacheName:
|
|
42
|
-
plugins: [
|
|
43
|
-
new CacheableResponsePlugin({
|
|
44
|
-
statuses: [0, 200],
|
|
45
|
-
}),
|
|
46
|
-
],
|
|
47
|
-
}),
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
// Cache CSS and JS files with StaleWhileRevalidate
|
|
51
|
-
registerRoute(
|
|
52
|
-
({ request }) =>
|
|
53
|
-
request.destination === 'style' ||
|
|
54
|
-
request.destination === 'script' ||
|
|
55
|
-
request.destination === 'worker',
|
|
56
|
-
new StaleWhileRevalidate({
|
|
57
|
-
cacheName: 'static-resources',
|
|
46
|
+
cacheName: CACHE.html,
|
|
58
47
|
plugins: [
|
|
59
48
|
new CacheableResponsePlugin({
|
|
60
49
|
statuses: [0, 200],
|
|
@@ -67,7 +56,7 @@ registerRoute(
|
|
|
67
56
|
registerRoute(
|
|
68
57
|
({ request }) => request.destination === 'font',
|
|
69
58
|
new CacheFirst({
|
|
70
|
-
cacheName:
|
|
59
|
+
cacheName: CACHE.fonts,
|
|
71
60
|
plugins: [
|
|
72
61
|
new CacheableResponsePlugin({
|
|
73
62
|
statuses: [0, 200],
|
|
@@ -87,5 +76,16 @@ self.addEventListener('message', (event) => {
|
|
|
87
76
|
});
|
|
88
77
|
|
|
89
78
|
self.addEventListener('activate', (event) => {
|
|
90
|
-
event.waitUntil(
|
|
79
|
+
event.waitUntil(
|
|
80
|
+
(async () => {
|
|
81
|
+
// Drop caches from older dev workers (unversioned names or another core version).
|
|
82
|
+
const names = await caches.keys();
|
|
83
|
+
await Promise.all(
|
|
84
|
+
names
|
|
85
|
+
.filter((name) => isStaleDevCache(name, coreVersion))
|
|
86
|
+
.map((name) => caches.delete(name)),
|
|
87
|
+
);
|
|
88
|
+
await self.clients.claim();
|
|
89
|
+
})(),
|
|
90
|
+
);
|
|
91
91
|
});
|