Loading CHANGES.md +3 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,9 @@ To be released. - `Service.clone()` method now accepts `service` option. - `Service.clone()` method now accepts `services` option. - In the `fedify inbox` command's web interface, the *Raw Activity* tab is added to show the raw JSON object of the received activity. [FEP-c0e0]: https://w3id.org/fep/c0e0 [FEP-9091]: https://w3id.org/fep/9091 [#146]: https://github.com/dahlia/fedify/issues/146 Loading cli/inbox/rendercode.ts +10 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,16 @@ export async function renderResponse(response: Response): Promise<string> { return code; } export async function renderRawActivity(request: Request): Promise<string> { request = request.clone(); try { const activity = await request.json(); return JSON.stringify(activity, null, 2); } catch { return "[Failed to decode body; it may not be JSON.]"; } } export async function renderActivity( activity: Activity, expand: boolean = false, Loading cli/inbox/view.tsx +29 −4 Original line number Diff line number Diff line import type { LogRecord } from "@logtape/logtape"; import { getStatusText } from "@poppanator/http-constants"; import type { FC, PropsWithChildren } from "hono/jsx"; import { getHighlighter } from "shiki"; import { getSingletonHighlighter } from "shiki"; import type { ActivityEntry } from "./entry.ts"; import { renderActivity, renderRequest, renderResponse } from "./rendercode.ts"; import { renderActivity, renderRawActivity, renderRequest, renderResponse, } from "./rendercode.ts"; interface LayoutProps { title?: string; Loading Loading @@ -103,7 +108,7 @@ interface CodeBlockProps { code: string; } const highlighter = await getHighlighter({ const highlighter = await getSingletonHighlighter({ themes: ["github-light"], langs: ["http", "json"], }); Loading Loading @@ -166,7 +171,13 @@ const LogList: FC<LogListProps> = ({ logs }: LogListProps) => { interface ActivityEntryViewProps { entry: ActivityEntry; tabPage: string; tabPage: | "request" | "response" | "raw-activity" | "compact-activity" | "expanded-activity" | "logs"; } const ActivityEntryView: FC<ActivityEntryViewProps> = async ( Loading @@ -187,6 +198,12 @@ const ActivityEntryView: FC<ActivityEntryViewProps> = async ( disabled={response == null} active={tabPage === "response"} /> <Tab label="Raw Activity" href="?tab=raw-activity" disabled={activity == null} active={tabPage === "raw-activity"} /> <Tab label="Compact Activity" href="?tab=compact-activity" Loading Loading @@ -222,6 +239,14 @@ const ActivityEntryView: FC<ActivityEntryViewProps> = async ( /> </div> )} {tabPage === "raw-activity" && ( <div class="tab-page"> <CodeBlock code={await renderRawActivity(request)} language="json" /> </div> )} {tabPage === "compact-activity" && activity != null && ( <div class="tab-page"> <CodeBlock Loading Loading
CHANGES.md +3 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,9 @@ To be released. - `Service.clone()` method now accepts `service` option. - `Service.clone()` method now accepts `services` option. - In the `fedify inbox` command's web interface, the *Raw Activity* tab is added to show the raw JSON object of the received activity. [FEP-c0e0]: https://w3id.org/fep/c0e0 [FEP-9091]: https://w3id.org/fep/9091 [#146]: https://github.com/dahlia/fedify/issues/146 Loading
cli/inbox/rendercode.ts +10 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,16 @@ export async function renderResponse(response: Response): Promise<string> { return code; } export async function renderRawActivity(request: Request): Promise<string> { request = request.clone(); try { const activity = await request.json(); return JSON.stringify(activity, null, 2); } catch { return "[Failed to decode body; it may not be JSON.]"; } } export async function renderActivity( activity: Activity, expand: boolean = false, Loading
cli/inbox/view.tsx +29 −4 Original line number Diff line number Diff line import type { LogRecord } from "@logtape/logtape"; import { getStatusText } from "@poppanator/http-constants"; import type { FC, PropsWithChildren } from "hono/jsx"; import { getHighlighter } from "shiki"; import { getSingletonHighlighter } from "shiki"; import type { ActivityEntry } from "./entry.ts"; import { renderActivity, renderRequest, renderResponse } from "./rendercode.ts"; import { renderActivity, renderRawActivity, renderRequest, renderResponse, } from "./rendercode.ts"; interface LayoutProps { title?: string; Loading Loading @@ -103,7 +108,7 @@ interface CodeBlockProps { code: string; } const highlighter = await getHighlighter({ const highlighter = await getSingletonHighlighter({ themes: ["github-light"], langs: ["http", "json"], }); Loading Loading @@ -166,7 +171,13 @@ const LogList: FC<LogListProps> = ({ logs }: LogListProps) => { interface ActivityEntryViewProps { entry: ActivityEntry; tabPage: string; tabPage: | "request" | "response" | "raw-activity" | "compact-activity" | "expanded-activity" | "logs"; } const ActivityEntryView: FC<ActivityEntryViewProps> = async ( Loading @@ -187,6 +198,12 @@ const ActivityEntryView: FC<ActivityEntryViewProps> = async ( disabled={response == null} active={tabPage === "response"} /> <Tab label="Raw Activity" href="?tab=raw-activity" disabled={activity == null} active={tabPage === "raw-activity"} /> <Tab label="Compact Activity" href="?tab=compact-activity" Loading Loading @@ -222,6 +239,14 @@ const ActivityEntryView: FC<ActivityEntryViewProps> = async ( /> </div> )} {tabPage === "raw-activity" && ( <div class="tab-page"> <CodeBlock code={await renderRawActivity(request)} language="json" /> </div> )} {tabPage === "compact-activity" && activity != null && ( <div class="tab-page"> <CodeBlock Loading