sh3-core 0.17.2 → 0.19.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/Sh3.svelte +59 -4
- package/dist/actions/CommandPalette.svelte +1 -2
- package/dist/actions/listeners.js +12 -1
- package/dist/api.d.ts +4 -0
- package/dist/app/store/storeShard.svelte.js +1 -21
- package/dist/app/store/version.d.ts +11 -0
- package/dist/app/store/version.js +39 -0
- package/dist/app/store/version.test.d.ts +1 -0
- package/dist/app/store/version.test.js +44 -0
- package/dist/apps/lifecycle.d.ts +6 -0
- package/dist/apps/lifecycle.js +5 -2
- package/dist/apps/lifecycle.test.js +30 -0
- package/dist/apps/types.d.ts +12 -0
- package/dist/assets/iconIds.generated.d.ts +1 -1
- package/dist/assets/iconIds.generated.js +5 -0
- package/dist/assets/icons.svg +31 -0
- package/dist/auth/auth.svelte.js +18 -8
- package/dist/auth/types.d.ts +6 -0
- package/dist/chrome/CompactChrome.svelte +54 -20
- package/dist/chrome/CompactChrome.svelte.test.js +112 -5
- package/dist/createShell.d.ts +9 -0
- package/dist/createShell.js +20 -7
- package/dist/createShell.remoteAuth.test.d.ts +1 -0
- package/dist/createShell.remoteAuth.test.js +71 -0
- package/dist/documents/http-backend.js +12 -11
- package/dist/env/client.js +11 -5
- package/dist/files/types.d.ts +106 -0
- package/dist/files/types.js +1 -0
- package/dist/gestures/gestureRegistry.d.ts +6 -0
- package/dist/gestures/gestureRegistry.js +190 -0
- package/dist/gestures/gestureRegistry.test.d.ts +1 -0
- package/dist/gestures/gestureRegistry.test.js +119 -0
- package/dist/gestures/index.d.ts +6 -0
- package/dist/gestures/index.js +12 -0
- package/dist/gestures/pointerClaim.d.ts +7 -0
- package/dist/gestures/pointerClaim.js +36 -0
- package/dist/gestures/pointerClaim.test.d.ts +1 -0
- package/dist/gestures/pointerClaim.test.js +64 -0
- package/dist/gestures/types.d.ts +83 -0
- package/dist/gestures/types.js +1 -0
- package/dist/host-entry.d.ts +1 -0
- package/dist/host-entry.js +1 -0
- package/dist/layout/LayoutRenderer.browser.test.js +15 -3
- package/dist/layout/LayoutRenderer.svelte +16 -3
- package/dist/layout/LayoutRenderer.svelte.d.ts +2 -0
- package/dist/layout/__screenshots__/LayoutRenderer.browser.test.ts/LayoutRenderer-browser---E-3-splitter-drag-updates-split-sizes-when-the-splitter-handle-is-dragged-1.png +0 -0
- package/dist/layout/__screenshots__/LayoutRenderer.browser.test.ts/LayoutRenderer-browser---E-5-splitter-collapse-toggle-toggles-collapsed-i--on-double-click-1.png +0 -0
- package/dist/layout/__screenshots__/LayoutRenderer.browser.test.ts/LayoutRenderer-browser---E-6-fixed-slots-hides-the-collapse-widget-on-a-fixed-pane-but-keeps-it-on-panes-with-a-non-fixed-neighbor-1.png +0 -0
- package/dist/layout/compact/CarouselTabs.svelte +361 -0
- package/dist/layout/compact/CarouselTabs.svelte.d.ts +10 -0
- package/dist/layout/compact/CarouselTabs.svelte.test.d.ts +1 -0
- package/dist/layout/compact/CarouselTabs.svelte.test.js +300 -0
- package/dist/layout/compact/CompactRenderer.svelte +1 -1
- package/dist/layout/compact/CompactRenderer.svelte.test.js +49 -0
- package/dist/layout/compact/derive.js +2 -0
- package/dist/layout/compact/derive.test.js +37 -0
- package/dist/layout/compact/enrichCarousels.d.ts +8 -0
- package/dist/layout/compact/enrichCarousels.js +44 -0
- package/dist/layout/compact/enrichCarousels.test.d.ts +1 -0
- package/dist/layout/compact/enrichCarousels.test.js +88 -0
- package/dist/layout/compact/types.d.ts +3 -0
- package/dist/layout/drag.svelte.js +13 -0
- package/dist/layout/store.schemaVersion.test.js +2 -2
- package/dist/layout/types.d.ts +9 -1
- package/dist/layout/types.js +1 -1
- package/dist/layout/types.test.d.ts +1 -0
- package/dist/layout/types.test.js +26 -0
- package/dist/overlays/ModalFrame.svelte +3 -1
- package/dist/overlays/ModalFrame.svelte.d.ts +1 -0
- package/dist/overlays/floatDismiss.js +5 -0
- package/dist/overlays/focusTrap.d.ts +11 -1
- package/dist/overlays/focusTrap.js +11 -9
- package/dist/overlays/modal.js +1 -0
- package/dist/overlays/popup.js +4 -0
- package/dist/overlays/types.d.ts +9 -0
- package/dist/primitives/Button.svelte +18 -0
- package/dist/primitives/Button.svelte.d.ts +6 -0
- package/dist/primitives/ResizableSplitter.svelte +71 -11
- package/dist/primitives/ResizableSplitter.svelte.d.ts +8 -0
- package/dist/primitives/ResizableSplitter.svelte.test.d.ts +1 -0
- package/dist/primitives/ResizableSplitter.svelte.test.js +74 -0
- package/dist/server-shard/types.d.ts +2 -1
- package/dist/shards/activate.svelte.js +10 -0
- package/dist/shards/ctx-fetch.test.d.ts +1 -0
- package/dist/shards/ctx-fetch.test.js +66 -0
- package/dist/shards/types.d.ts +13 -0
- package/dist/transport/apiFetch.d.ts +1 -0
- package/dist/transport/apiFetch.js +65 -0
- package/dist/transport/apiFetch.test.d.ts +1 -0
- package/dist/transport/apiFetch.test.js +37 -0
- package/dist/transport/authToken.d.ts +2 -0
- package/dist/transport/authToken.js +53 -0
- package/dist/transport/authToken.test.d.ts +1 -0
- package/dist/transport/authToken.test.js +33 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
describe('apiFetch', () => {
|
|
3
|
+
let originalFetch;
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
originalFetch = globalThis.fetch;
|
|
6
|
+
vi.resetModules();
|
|
7
|
+
});
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
globalThis.fetch = originalFetch;
|
|
10
|
+
});
|
|
11
|
+
it('uses global fetch with credentials:include when Tauri plugin-http is unavailable', async () => {
|
|
12
|
+
const calls = [];
|
|
13
|
+
globalThis.fetch = vi.fn(async (input, init) => {
|
|
14
|
+
calls.push([input, init]);
|
|
15
|
+
return new Response('ok');
|
|
16
|
+
});
|
|
17
|
+
const { apiFetch } = await import('./apiFetch');
|
|
18
|
+
const res = await apiFetch('https://example.com/api/foo', { method: 'GET' });
|
|
19
|
+
expect(await res.text()).toBe('ok');
|
|
20
|
+
expect(calls).toHaveLength(1);
|
|
21
|
+
const [input, init] = calls[0];
|
|
22
|
+
expect(input).toBe('https://example.com/api/foo');
|
|
23
|
+
expect(init.credentials).toBe('include');
|
|
24
|
+
expect(init.method).toBe('GET');
|
|
25
|
+
});
|
|
26
|
+
it('lets caller-provided credentials override the default', async () => {
|
|
27
|
+
const calls = [];
|
|
28
|
+
globalThis.fetch = vi.fn(async (input, init) => {
|
|
29
|
+
calls.push([input, init]);
|
|
30
|
+
return new Response('ok');
|
|
31
|
+
});
|
|
32
|
+
const { apiFetch } = await import('./apiFetch');
|
|
33
|
+
await apiFetch('https://example.com/api/foo', { credentials: 'omit' });
|
|
34
|
+
const [, init] = calls[0];
|
|
35
|
+
expect(init.credentials).toBe('omit');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Auth-token store used by `apiFetch` to attach `Authorization: Bearer
|
|
3
|
+
* <token>` to every request when a session exists.
|
|
4
|
+
*
|
|
5
|
+
* The browser auth flow relies on Set-Cookie + same-origin requests to
|
|
6
|
+
* keep the session alive. That breaks down for cross-origin Tauri
|
|
7
|
+
* clients (e.g. Android): the WebView's origin is `tauri://localhost`
|
|
8
|
+
* and the sh3-server lives on a different domain, so the session
|
|
9
|
+
* cookie is treated as cross-site and dropped under SameSite=Lax. On
|
|
10
|
+
* top of that, `@tauri-apps/plugin-http` (reqwest under the hood)
|
|
11
|
+
* doesn't enable a persistent cookie store by default, so even if
|
|
12
|
+
* SameSite weren't an issue cookies wouldn't survive between calls.
|
|
13
|
+
*
|
|
14
|
+
* Carrying the session token in a header sidesteps both problems.
|
|
15
|
+
* `auth.svelte.ts` populates this store after login/register/initFromBoot
|
|
16
|
+
* and clears it on logout. The token is mirrored to localStorage so an
|
|
17
|
+
* app restart doesn't dump the user back at the sign-in wall.
|
|
18
|
+
*/
|
|
19
|
+
const KEY = 'sh3:authToken';
|
|
20
|
+
let token = null;
|
|
21
|
+
let restored = false;
|
|
22
|
+
function restore() {
|
|
23
|
+
if (restored)
|
|
24
|
+
return;
|
|
25
|
+
restored = true;
|
|
26
|
+
if (typeof localStorage === 'undefined')
|
|
27
|
+
return;
|
|
28
|
+
try {
|
|
29
|
+
token = localStorage.getItem(KEY);
|
|
30
|
+
}
|
|
31
|
+
catch (_a) {
|
|
32
|
+
token = null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function setAuthToken(value) {
|
|
36
|
+
restored = true;
|
|
37
|
+
token = value;
|
|
38
|
+
if (typeof localStorage === 'undefined')
|
|
39
|
+
return;
|
|
40
|
+
try {
|
|
41
|
+
if (value)
|
|
42
|
+
localStorage.setItem(KEY, value);
|
|
43
|
+
else
|
|
44
|
+
localStorage.removeItem(KEY);
|
|
45
|
+
}
|
|
46
|
+
catch (_a) {
|
|
47
|
+
// localStorage may be disabled (private browsing); in-memory copy still works.
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export function getAuthToken() {
|
|
51
|
+
restore();
|
|
52
|
+
return token;
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, expect, it, beforeEach, vi } from 'vitest';
|
|
2
|
+
describe('authToken', () => {
|
|
3
|
+
beforeEach(() => {
|
|
4
|
+
vi.resetModules();
|
|
5
|
+
if (typeof localStorage !== 'undefined')
|
|
6
|
+
localStorage.clear();
|
|
7
|
+
});
|
|
8
|
+
it('returns null when nothing stored', async () => {
|
|
9
|
+
const { getAuthToken } = await import('./authToken');
|
|
10
|
+
expect(getAuthToken()).toBeNull();
|
|
11
|
+
});
|
|
12
|
+
it('round-trips set/get', async () => {
|
|
13
|
+
const { setAuthToken, getAuthToken } = await import('./authToken');
|
|
14
|
+
setAuthToken('sh3s_deadbeef');
|
|
15
|
+
expect(getAuthToken()).toBe('sh3s_deadbeef');
|
|
16
|
+
});
|
|
17
|
+
it('persists across module re-imports via localStorage', async () => {
|
|
18
|
+
const first = await import('./authToken');
|
|
19
|
+
first.setAuthToken('sh3s_persisted');
|
|
20
|
+
vi.resetModules();
|
|
21
|
+
const second = await import('./authToken');
|
|
22
|
+
expect(second.getAuthToken()).toBe('sh3s_persisted');
|
|
23
|
+
});
|
|
24
|
+
it('clear removes from storage', async () => {
|
|
25
|
+
const { setAuthToken, getAuthToken } = await import('./authToken');
|
|
26
|
+
setAuthToken('sh3s_x');
|
|
27
|
+
setAuthToken(null);
|
|
28
|
+
expect(getAuthToken()).toBeNull();
|
|
29
|
+
vi.resetModules();
|
|
30
|
+
const reloaded = await import('./authToken');
|
|
31
|
+
expect(reloaded.getAuthToken()).toBeNull();
|
|
32
|
+
});
|
|
33
|
+
});
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Auto-generated from package.json — do not edit manually. */
|
|
2
|
-
export declare const VERSION = "0.
|
|
2
|
+
export declare const VERSION = "0.19.0";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Auto-generated from package.json — do not edit manually. */
|
|
2
|
-
export const VERSION = '0.
|
|
2
|
+
export const VERSION = '0.19.0';
|