mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-25 02:41:21 +01:00
Add .oxfmtignore to skip generated bindings and wasm-pack output. Add npm format script, update DEVELOPMENT.md for Vite+ toolchain, and format all non-generated files with oxfmt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import { readFile } from "@tauri-apps/plugin-fs";
|
|
import type { HttpResponse } from "@yaakapp-internal/models";
|
|
import type { FilterResponse } from "@yaakapp-internal/plugins";
|
|
import type { ServerSentEvent } from "@yaakapp-internal/sse";
|
|
import { invokeCmd } from "./tauri";
|
|
|
|
export async function getResponseBodyText({
|
|
response,
|
|
filter,
|
|
}: {
|
|
response: HttpResponse;
|
|
filter: string | null;
|
|
}): Promise<string | null> {
|
|
const result = await invokeCmd<FilterResponse>("cmd_http_response_body", {
|
|
response,
|
|
filter,
|
|
});
|
|
|
|
if (result.error) {
|
|
throw new Error(result.error);
|
|
}
|
|
|
|
return result.content;
|
|
}
|
|
|
|
export async function getResponseBodyEventSource(
|
|
response: HttpResponse,
|
|
): Promise<ServerSentEvent[]> {
|
|
if (!response.bodyPath) return [];
|
|
return invokeCmd<ServerSentEvent[]>("cmd_get_sse_events", {
|
|
filePath: response.bodyPath,
|
|
});
|
|
}
|
|
|
|
export async function getResponseBodyBytes(
|
|
response: HttpResponse,
|
|
): Promise<Uint8Array<ArrayBuffer> | null> {
|
|
if (!response.bodyPath) return null;
|
|
return readFile(response.bodyPath);
|
|
}
|