GraphQL, WebSocket, import, runner and CLI (M5, M6) plus packaging

- GraphQL editor with schema introspection, cached schema,
  autocomplete and explorer
- WebSocket: auth and subprotocols in the handshake, text/JSON/hex/file
  messages, saved messages, live log with filter, search and export,
  reconnect with backoff
- Import from Postman (collections and environments), Bruno, Insomnia,
  OpenAPI/Swagger and cURL; imported scripts are kept as docs, never run;
  credentials move to the gitignored secrets file
- Code snippets for cURL, fetch, Python, HTTPie, Go, PowerShell;
  Postman export
- Runner for folders and collections with JSON and JUnit reports
- knock CLI: send, run, import, auth login/debug/logout
- Large JSON responses parsed off the main thread
- PKGBUILDs, desktop entry with knock:// handler, CI workflow, README
This commit is contained in:
2026-11-27 17:13:06 +01:00
parent a469697af7
commit fc253126a7
51 changed files with 8437 additions and 24 deletions
+29
View File
@@ -0,0 +1,29 @@
import type { JNode } from './ast';
import { parse, serialize } from './ast';
let worker: Worker | null = null;
let seq = 0;
const pending = new Map<number, (r: { tree?: JNode; pretty?: string; error?: string }) => void>();
/** Parses large JSON off the main thread so a 50 MB body does not freeze the UI. */
export function parseJson(text: string): Promise<{ tree: JNode | null; pretty: string; error?: string }> {
if (text.length < 512 * 1024) {
try {
const tree = parse(text);
return Promise.resolve({ tree, pretty: serialize(tree, ' ') });
} catch (e) {
return Promise.resolve({ tree: null, pretty: text, error: String((e as Error).message) });
}
}
worker ??= new Worker(new URL('./parse.worker.ts', import.meta.url), { type: 'module' });
worker.onmessage = (e) => {
const cb = pending.get(e.data.id);
pending.delete(e.data.id);
cb?.(e.data);
};
const id = ++seq;
return new Promise((resolve) => {
pending.set(id, (r) => resolve({ tree: r.tree ?? null, pretty: r.pretty ?? text, error: r.error }));
worker!.postMessage({ id, text });
});
}