mirror of
https://github.com/JoshiCodes/knock.git
synced 2026-12-04 15:29:40 +01:00
Pop-out auth debugger, cURL paste into the sidebar, desktop entry matches app id
- The auth debugger opens in its own window on request - Ctrl+V with a cURL command in the sidebar creates a request in the selected folder - knock-app.desktop and icon names match the Wayland app id, so KDE shows the icon in the taskbar
This commit is contained in:
@@ -36,11 +36,11 @@ package() {
|
|||||||
cd "$pkgname"
|
cd "$pkgname"
|
||||||
install -Dm755 target/release/knock-app "$pkgdir/usr/bin/knock-app"
|
install -Dm755 target/release/knock-app "$pkgdir/usr/bin/knock-app"
|
||||||
install -Dm755 target/release/knock "$pkgdir/usr/bin/knock"
|
install -Dm755 target/release/knock "$pkgdir/usr/bin/knock"
|
||||||
install -Dm644 packaging/linux/de.joshicodes.knock.desktop "$pkgdir/usr/share/applications/de.joshicodes.knock.desktop"
|
install -Dm644 packaging/linux/knock-app.desktop "$pkgdir/usr/share/applications/knock-app.desktop"
|
||||||
install -Dm644 logo/knock-app-icon.svg "$pkgdir/usr/share/icons/hicolor/scalable/apps/knock.svg"
|
install -Dm644 logo/knock-app-icon.svg "$pkgdir/usr/share/icons/hicolor/scalable/apps/knock-app.svg"
|
||||||
for s in 32 128; do
|
for s in 32 128; do
|
||||||
install -Dm644 "src-tauri/icons/${s}x${s}.png" "$pkgdir/usr/share/icons/hicolor/${s}x${s}/apps/knock.png"
|
install -Dm644 "src-tauri/icons/${s}x${s}.png" "$pkgdir/usr/share/icons/hicolor/${s}x${s}/apps/knock-app.png"
|
||||||
done
|
done
|
||||||
install -Dm644 src-tauri/icons/[email protected] "$pkgdir/usr/share/icons/hicolor/256x256/apps/knock.png"
|
install -Dm644 src-tauri/icons/[email protected] "$pkgdir/usr/share/icons/hicolor/256x256/apps/knock-app.png"
|
||||||
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Name=knock
|
|||||||
GenericName=API Client
|
GenericName=API Client
|
||||||
Comment=Send HTTP, GraphQL and WebSocket requests
|
Comment=Send HTTP, GraphQL and WebSocket requests
|
||||||
Exec=knock-app %u
|
Exec=knock-app %u
|
||||||
Icon=knock
|
Icon=knock-app
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Categories=Development;Network;
|
Categories=Development;Network;
|
||||||
Keywords=api;http;rest;graphql;websocket;oauth;postman;bruno;
|
Keywords=api;http;rest;graphql;websocket;oauth;postman;bruno;
|
||||||
@@ -2,7 +2,10 @@
|
|||||||
"$schema": "../gen/schemas/desktop-schema.json",
|
"$schema": "../gen/schemas/desktop-schema.json",
|
||||||
"identifier": "default",
|
"identifier": "default",
|
||||||
"description": "Main window",
|
"description": "Main window",
|
||||||
"windows": ["main"],
|
"windows": [
|
||||||
|
"main",
|
||||||
|
"debug-*"
|
||||||
|
],
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"core:default",
|
"core:default",
|
||||||
"core:window:allow-start-dragging",
|
"core:window:allow-start-dragging",
|
||||||
@@ -13,6 +16,8 @@
|
|||||||
"core:window:allow-start-resize-dragging",
|
"core:window:allow-start-resize-dragging",
|
||||||
"dialog:default",
|
"dialog:default",
|
||||||
"opener:default",
|
"opener:default",
|
||||||
"deep-link:default"
|
"deep-link:default",
|
||||||
|
"core:webview:allow-create-webview-window",
|
||||||
|
"core:window:allow-set-title"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { Toaster } from '@joshicodes/cock';
|
||||||
|
import AuthDebugView from '$lib/views/auth/AuthDebugView.svelte';
|
||||||
|
import type { AuthDebug } from '$lib/types';
|
||||||
|
|
||||||
|
let { id }: { id: string } = $props();
|
||||||
|
|
||||||
|
// Snapshot handed over by the main window; it is removed once read.
|
||||||
|
let data = $state<{ debug: AuthDebug; title: string } | null>(null);
|
||||||
|
$effect(() => {
|
||||||
|
const key = `knock.debug.${id}`;
|
||||||
|
try {
|
||||||
|
const raw = localStorage.getItem(key);
|
||||||
|
if (raw) data = JSON.parse(raw);
|
||||||
|
localStorage.removeItem(key);
|
||||||
|
} catch {
|
||||||
|
data = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="flex h-full flex-col bg-panel text-fg">
|
||||||
|
{#if data}
|
||||||
|
<div class="k-label border-b border-line px-3 py-2">Auth debugger · {data.title}</div>
|
||||||
|
<div class="min-h-0 flex-1"><AuthDebugView debug={data.debug} detached /></div>
|
||||||
|
{:else}
|
||||||
|
<p class="p-4 text-fg-muted">Nothing to show.</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<Toaster position="bottom-right" />
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
import type { CollectionView, TreeNode } from '$lib/types';
|
import type { CollectionView, TreeNode } from '$lib/types';
|
||||||
import HistoryPanel from './HistoryPanel.svelte';
|
import HistoryPanel from './HistoryPanel.svelte';
|
||||||
import { dialogs } from '$lib/state/dialogs.svelte';
|
import { dialogs } from '$lib/state/dialogs.svelte';
|
||||||
|
import { looksLikeCurl, parseCurl } from '$lib/curl';
|
||||||
|
|
||||||
const ROW = 26;
|
const ROW = 26;
|
||||||
|
|
||||||
@@ -177,6 +178,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Ctrl+V with a cURL command creates a request in the selected folder. */
|
||||||
|
async function pasteCurl(e: ClipboardEvent) {
|
||||||
|
const text = e.clipboardData?.getData('text/plain') ?? '';
|
||||||
|
if (!looksLikeCurl(text)) return;
|
||||||
|
e.preventDefault();
|
||||||
|
const r = rows.find((x) => x.key === selected) ?? null;
|
||||||
|
const col = r?.col.id ?? ws.focusCol;
|
||||||
|
if (!col) return;
|
||||||
|
try {
|
||||||
|
const req = await parseCurl(text);
|
||||||
|
const res = await api.requestCreate(col, folderOf(r), req);
|
||||||
|
ws.upsert(res.collection);
|
||||||
|
await ws.openRequest(col, res.id, false);
|
||||||
|
toast.success('Request created from cURL');
|
||||||
|
} catch (err) {
|
||||||
|
toast.error('Could not import cURL', { description: errorText(err) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function addFolder(r: Row | null) {
|
async function addFolder(r: Row | null) {
|
||||||
const col = r?.col.id ?? ws.focusCol;
|
const col = r?.col.id ?? ws.focusCol;
|
||||||
if (!col) return;
|
if (!col) return;
|
||||||
@@ -393,6 +413,7 @@
|
|||||||
aria-label="Collections"
|
aria-label="Collections"
|
||||||
onscroll={(e) => (scrollTop = (e.currentTarget as HTMLElement).scrollTop)}
|
onscroll={(e) => (scrollTop = (e.currentTarget as HTMLElement).scrollTop)}
|
||||||
onkeydown={keydown}
|
onkeydown={keydown}
|
||||||
|
onpaste={pasteCurl}
|
||||||
>
|
>
|
||||||
<div style:height="{rows.length * ROW}px" class="relative">
|
<div style:height="{rows.length * ROW}px" class="relative">
|
||||||
{#each rows.slice(first, last) as r, i (r.key)}
|
{#each rows.slice(first, last) as r, i (r.key)}
|
||||||
|
|||||||
@@ -1,12 +1,28 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { toast } from '@joshicodes/cock';
|
import { toast } from '@joshicodes/cock';
|
||||||
|
import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
|
||||||
import Icon from '$lib/ui/Icon.svelte';
|
import Icon from '$lib/ui/Icon.svelte';
|
||||||
import { ws, type Tab } from '$lib/state/workspace.svelte';
|
import { ws, type Tab } from '$lib/state/workspace.svelte';
|
||||||
import type { AuthDebug, Exchange, Json } from '$lib/types';
|
import type { AuthDebug, Exchange, Json } from '$lib/types';
|
||||||
import TokenInspector from './TokenInspector.svelte';
|
import TokenInspector from './TokenInspector.svelte';
|
||||||
import { formatMs } from '$lib/request';
|
import { formatMs } from '$lib/request';
|
||||||
|
|
||||||
let { debug, tab }: { debug: AuthDebug; tab?: Tab } = $props();
|
let { debug, tab, detached = false }: { debug: AuthDebug; tab?: Tab; detached?: boolean } = $props();
|
||||||
|
|
||||||
|
function popOut() {
|
||||||
|
const id = crypto.randomUUID().slice(0, 8);
|
||||||
|
try {
|
||||||
|
localStorage.setItem(`knock.debug.${id}`, JSON.stringify({ debug, title: tab?.title ?? debug.kind }));
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new WebviewWindow(`debug-${id}`, {
|
||||||
|
url: `index.html#debug=${id}`,
|
||||||
|
title: `Auth debugger · ${tab?.title ?? debug.kind}`,
|
||||||
|
width: 760,
|
||||||
|
height: 820
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let open = $state<Record<string, boolean>>({});
|
let open = $state<Record<string, boolean>>({});
|
||||||
let firstError = $derived(debug.steps.findIndex((s) => s.status === 'error'));
|
let firstError = $derived(debug.steps.findIndex((s) => s.status === 'error'));
|
||||||
@@ -79,6 +95,9 @@
|
|||||||
<div class="mb-3 flex items-center gap-3">
|
<div class="mb-3 flex items-center gap-3">
|
||||||
<span class="text-fg"><span class="font-bold">{debug.kind}</span> <span class="text-fg-muted">from the {debug.origin}{debug.origin !== 'request' ? ` (${debug.source})` : ''}</span></span>
|
<span class="text-fg"><span class="font-bold">{debug.kind}</span> <span class="text-fg-muted">from the {debug.origin}{debug.origin !== 'request' ? ` (${debug.source})` : ''}</span></span>
|
||||||
<span class="flex-1"></span>
|
<span class="flex-1"></span>
|
||||||
|
{#if !detached}
|
||||||
|
<button class="text-[12px] text-fg-muted hover:text-fg" onclick={popOut} title="Open in its own window">Open in window</button>
|
||||||
|
{/if}
|
||||||
{#if debug.steps.length > 1}
|
{#if debug.steps.length > 1}
|
||||||
<button class="text-[12px] text-fg-muted hover:text-fg" onclick={() => exportFlow('md')}>Copy as Markdown</button>
|
<button class="text-[12px] text-fg-muted hover:text-fg" onclick={() => exportFlow('md')}>Copy as Markdown</button>
|
||||||
<button class="text-[12px] text-fg-muted hover:text-fg" onclick={() => exportFlow('json')}>Copy as JSON</button>
|
<button class="text-[12px] text-fg-muted hover:text-fg" onclick={() => exportFlow('json')}>Copy as JSON</button>
|
||||||
|
|||||||
+4
-1
@@ -1,8 +1,11 @@
|
|||||||
import { mount } from 'svelte';
|
import { mount } from 'svelte';
|
||||||
import './app.css';
|
import './app.css';
|
||||||
import App from './App.svelte';
|
import App from './App.svelte';
|
||||||
|
import DebugWindow from './DebugWindow.svelte';
|
||||||
|
|
||||||
const app = mount(App, { target: document.getElementById('app')! });
|
const debugId = new URLSearchParams(location.hash.slice(1)).get('debug');
|
||||||
|
const target = document.getElementById('app')!;
|
||||||
|
const app = debugId ? mount(DebugWindow, { target, props: { id: debugId } }) : mount(App, { target });
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user