pi-better-show 0.3.0 → 0.4.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/README.md +39 -5
- package/bin/pbs-tree.js +424 -0
- package/package.json +5 -1
- package/src/core/parse.ts +2 -0
- package/src/core/text.ts +24 -0
- package/src/core/tree.ts +84 -0
- package/src/core/types.ts +34 -1
- package/src/core/validate.ts +10 -0
- package/src/elements/index.ts +4 -0
- package/src/elements/strings.ts +13 -0
- package/src/elements/tree.ts +261 -0
- package/src/extension/client/bridge.ts +29 -0
- package/src/extension/client/feedback.ts +38 -16
- package/src/extension/client/frame.ts +27 -1
- package/src/extension/client/host-config.ts +20 -0
- package/src/extension/client/host-page.ts +73 -0
- package/src/extension/client/host.ts +12 -24
- package/src/extension/client/page.ts +3 -12
- package/src/extension/controller.ts +34 -16
- package/src/extension/index.ts +1 -2
- package/src/extension/server.ts +20 -2
- package/src/extension/tool.ts +7 -3
- package/src/react/index.ts +3 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Answer } from "../../core/types.ts";
|
|
1
2
|
import { configure } from "../../elements/index.ts";
|
|
2
3
|
|
|
3
4
|
/** The page server's path prefix (`/<token>`): the first segment of every page it serves. */
|
|
@@ -44,6 +45,25 @@ export interface AnswerReply {
|
|
|
44
45
|
reason?: string;
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
export interface AnswerBody {
|
|
49
|
+
answerId: string;
|
|
50
|
+
answer: Answer;
|
|
51
|
+
/** The path of the page the answer comes from. */
|
|
52
|
+
page: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Delivers one answer to the page server, and tells whether it was taken. */
|
|
56
|
+
export type PostAnswer = (url: string, body: AnswerBody) => Promise<AnswerReply>;
|
|
57
|
+
|
|
58
|
+
export const postAnswerToServer: PostAnswer = async (url, body) => {
|
|
59
|
+
const response = await fetch(url, {
|
|
60
|
+
method: "POST",
|
|
61
|
+
headers: { "content-type": "application/json" },
|
|
62
|
+
body: JSON.stringify(body),
|
|
63
|
+
});
|
|
64
|
+
return (await response.json().catch(() => ({ accepted: false, reason: `HTTP ${response.status}` }))) as AnswerReply;
|
|
65
|
+
};
|
|
66
|
+
|
|
47
67
|
/** A random id for one answer, so a repeated send is delivered once. */
|
|
48
68
|
export const newAnswerId = (): string =>
|
|
49
69
|
typeof crypto.randomUUID === "function"
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { frameAnswer, frameSelection } from "./bridge.ts";
|
|
2
|
+
import { type FeedbackWords, mountFeedback } from "./feedback.ts";
|
|
3
|
+
import { type AnswerReply, newAnswerId, type PostAnswer } from "./host-config.ts";
|
|
4
|
+
|
|
5
|
+
export interface HostOptions {
|
|
6
|
+
frame: HTMLIFrameElement;
|
|
7
|
+
/** The page server's path prefix (`/<token>`). */
|
|
8
|
+
prefix: string;
|
|
9
|
+
/** The name the agent knows the page by: the HTML title, else the file name. */
|
|
10
|
+
page: string;
|
|
11
|
+
words: FeedbackWords;
|
|
12
|
+
storage: Pick<Storage, "getItem" | "setItem" | "removeItem">;
|
|
13
|
+
storageKey: string;
|
|
14
|
+
post: PostAnswer;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The page around an agent's HTML or TSX page. The page itself runs in a sandboxed frame without `allow-same-origin`,
|
|
19
|
+
* so the server refuses its own requests (Origin null); it asks this parent, by `postMessage`, to carry its answers and
|
|
20
|
+
* to report the text the user selects. The parent trusts a message only from its own frame (see bridge.ts), and the
|
|
21
|
+
* feedback panel lives here, outside the frame, where the user's comments and the server's answer check are the same
|
|
22
|
+
* as on a Markdown page.
|
|
23
|
+
*/
|
|
24
|
+
export function mountHost(options: HostOptions): { destroy: () => void } {
|
|
25
|
+
const { frame, prefix, post } = options;
|
|
26
|
+
const answerUrl = `${prefix}/answer`;
|
|
27
|
+
const feedback = mountFeedback({
|
|
28
|
+
page: options.page,
|
|
29
|
+
words: options.words,
|
|
30
|
+
storage: options.storage,
|
|
31
|
+
storageKey: options.storageKey,
|
|
32
|
+
watchDocument: false,
|
|
33
|
+
send: async (answer) => {
|
|
34
|
+
const reply = await post(answerUrl, { answerId: newAnswerId(), answer, page: location.pathname });
|
|
35
|
+
if (!reply.accepted) throw new Error(reply.reason ?? "refused");
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const onMessage = (event: MessageEvent): void => {
|
|
40
|
+
const selection = frameSelection(event, frame.contentWindow);
|
|
41
|
+
if (selection) {
|
|
42
|
+
// The position is in the frame's viewport; the Add button sits in this one.
|
|
43
|
+
const origin = frame.getBoundingClientRect();
|
|
44
|
+
feedback.offer({
|
|
45
|
+
text: selection.text,
|
|
46
|
+
...(selection.top === undefined ? {} : { top: selection.top + origin.top }),
|
|
47
|
+
...(selection.left === undefined ? {} : { left: selection.left + origin.left }),
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const taken = frameAnswer(event, frame.contentWindow);
|
|
52
|
+
if (!taken) return;
|
|
53
|
+
const reply = (result: AnswerReply): void =>
|
|
54
|
+
frame.contentWindow?.postMessage(
|
|
55
|
+
{ source: "pbs-host", type: "answer-result", answerId: taken.answerId, ...result },
|
|
56
|
+
"*",
|
|
57
|
+
);
|
|
58
|
+
post(answerUrl, { ...taken, page: location.pathname }).then(reply, (error: unknown) =>
|
|
59
|
+
reply({ accepted: false, reason: error instanceof Error ? error.message : String(error) }),
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
// A frame that loads again has lost its selection.
|
|
63
|
+
const onLoad = (): void => feedback.offer(undefined);
|
|
64
|
+
window.addEventListener("message", onMessage);
|
|
65
|
+
frame.addEventListener("load", onLoad);
|
|
66
|
+
return {
|
|
67
|
+
destroy: () => {
|
|
68
|
+
window.removeEventListener("message", onMessage);
|
|
69
|
+
frame.removeEventListener("load", onLoad);
|
|
70
|
+
feedback.destroy();
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -1,33 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { wordsFor } from "./feedback.ts";
|
|
2
|
+
import { postAnswerToServer, serverPrefix } from "./host-config.ts";
|
|
3
|
+
import { mountHost } from "./host-page.ts";
|
|
3
4
|
|
|
4
|
-
/**
|
|
5
|
-
* The page around an agent's HTML or TSX page. The page itself runs in a sandboxed frame without
|
|
6
|
-
* `allow-same-origin`, so the server refuses its own requests (Origin null); it asks this parent, by `postMessage`, to carry its answers.
|
|
7
|
-
* The parent trusts a message only from its own frame (see bridge.ts).
|
|
8
|
-
*/
|
|
5
|
+
/** The script of the page around an agent's HTML or TSX page: carries its answers, mounts the feedback panel, and reloads the frame when the document changes. */
|
|
9
6
|
|
|
10
7
|
const prefix = serverPrefix();
|
|
11
8
|
const frame = document.querySelector("iframe");
|
|
12
9
|
if (!frame) throw new Error("no frame to host");
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
fetch(`${prefix}/answer`, {
|
|
23
|
-
method: "POST",
|
|
24
|
-
headers: { "content-type": "application/json" },
|
|
25
|
-
body: JSON.stringify({ ...taken, page: location.pathname }),
|
|
26
|
-
})
|
|
27
|
-
.then((response) => response.json() as Promise<AnswerReply>)
|
|
28
|
-
.then(reply, (error: unknown) =>
|
|
29
|
-
reply({ accepted: false, reason: error instanceof Error ? error.message : String(error) }),
|
|
30
|
-
);
|
|
11
|
+
mountHost({
|
|
12
|
+
frame,
|
|
13
|
+
prefix,
|
|
14
|
+
page: document.title || location.pathname.split("/").pop() || "",
|
|
15
|
+
words: wordsFor(document.documentElement.lang || navigator.language),
|
|
16
|
+
storage: sessionStorage,
|
|
17
|
+
storageKey: `pbs-feedback:${location.pathname}`,
|
|
18
|
+
post: postAnswerToServer,
|
|
31
19
|
});
|
|
32
20
|
|
|
33
21
|
new EventSource(`${prefix}/events?page=${encodeURIComponent(location.pathname)}`).addEventListener("reload", () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Answer } from "../../core/types.ts";
|
|
2
2
|
import "../../elements/index.ts";
|
|
3
3
|
import { mountFeedback, wordsFor } from "./feedback.ts";
|
|
4
|
-
import { type AnswerReply, configureElements, newAnswerId, serverPrefix } from "./host-config.ts";
|
|
4
|
+
import { type AnswerReply, configureElements, newAnswerId, postAnswerToServer, serverPrefix } from "./host-config.ts";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The script of a rendered Markdown page: wires the elements to the page server (diagrams, images, answers),
|
|
@@ -11,17 +11,8 @@ import { type AnswerReply, configureElements, newAnswerId, serverPrefix } from "
|
|
|
11
11
|
const prefix = serverPrefix();
|
|
12
12
|
configureElements(prefix);
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
method: "POST",
|
|
17
|
-
headers: { "content-type": "application/json" },
|
|
18
|
-
body: JSON.stringify({ answerId: newAnswerId(), answer, page: location.pathname }),
|
|
19
|
-
});
|
|
20
|
-
const reply = (await response
|
|
21
|
-
.json()
|
|
22
|
-
.catch(() => ({ accepted: false, reason: `HTTP ${response.status}` }))) as AnswerReply;
|
|
23
|
-
return reply;
|
|
24
|
-
}
|
|
14
|
+
const postAnswer = (answer: Answer): Promise<AnswerReply> =>
|
|
15
|
+
postAnswerToServer(`${prefix}/answer`, { answerId: newAnswerId(), answer, page: location.pathname });
|
|
25
16
|
|
|
26
17
|
const toast = (text: string): void => {
|
|
27
18
|
const box = document.createElement("div");
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import { homedir, tmpdir } from "node:os";
|
|
14
14
|
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
15
15
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
16
|
-
import { encodeAnswer } from "../core/
|
|
16
|
+
import { encodeAnswer } from "../core/answer.ts";
|
|
17
17
|
import type { Answer } from "../core/types.ts";
|
|
18
18
|
import {
|
|
19
19
|
ANSWER_EVENT,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
} from "./contract.ts";
|
|
29
29
|
import { createEditSession, defaultLaunch, defaultRun, EDITOR_ENV, type EditDeps, WATCH_MS } from "./edit.ts";
|
|
30
30
|
import { createAllowList, HTML_FILE, IMAGE_FILE, MARKDOWN_FILE, REACT_FILE } from "./files.ts";
|
|
31
|
-
import {
|
|
31
|
+
import type { PageServer, PageServerOptions } from "./server.ts";
|
|
32
32
|
|
|
33
33
|
export const MESSAGE_TYPE = "better-show";
|
|
34
34
|
export const MINI_SDD_FILE = /(^|\/)docs\/specs\/[^/]+\/(decision|spec|design|verification)\.md$/;
|
|
@@ -59,6 +59,13 @@ export interface Deps extends EditDeps {
|
|
|
59
59
|
now: () => number;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Starts the page server, loading it (with the renderers, Mermaid, and the page bundler it pulls in) on the first
|
|
64
|
+
* call. An idle session that never shows a page never pays for any of it.
|
|
65
|
+
*/
|
|
66
|
+
export const createPageServer = async (options: PageServerOptions): Promise<PageServer> =>
|
|
67
|
+
(await import("./server.ts")).createPageServer(options);
|
|
68
|
+
|
|
62
69
|
export const defaultDeps = (): Deps => ({
|
|
63
70
|
editor: process.env[EDITOR_ENV],
|
|
64
71
|
onPath: (command) => spawnSync("sh", ["-c", 'command -v "$1"', "sh", command], { stdio: "ignore" }).status === 0,
|
|
@@ -174,21 +181,32 @@ export function createBetterShow(pi: ExtensionAPI, deps: Deps = defaultDeps()) {
|
|
|
174
181
|
const pathOfDoc = (id: string): string | undefined => [...docs.values()].find((entry) => entry.id === id)?.path;
|
|
175
182
|
const displayOf = (path: string): string => docs.get(path)?.display ?? basename(path);
|
|
176
183
|
|
|
184
|
+
/** The server being started; two first uses at once share it, so only one server listens. */
|
|
185
|
+
let starting: Promise<PageServer> | undefined;
|
|
177
186
|
const ensureServer = async (): Promise<PageServer> => {
|
|
178
|
-
server
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
187
|
+
if (server) return server;
|
|
188
|
+
starting ??= deps
|
|
189
|
+
.servePages({
|
|
190
|
+
canServe: allow.canServe,
|
|
191
|
+
pathOfDoc,
|
|
192
|
+
displayOf,
|
|
193
|
+
onAnswer: ({ answerId, answer, page }) => {
|
|
194
|
+
const entry = page ? docs.get(page) : undefined;
|
|
195
|
+
const result = decide(entry?.id, answerId, answer, true);
|
|
196
|
+
return result.reason === undefined
|
|
197
|
+
? { accepted: result.accepted }
|
|
198
|
+
: { accepted: result.accepted, reason: result.reason };
|
|
199
|
+
},
|
|
200
|
+
onIdle,
|
|
201
|
+
})
|
|
202
|
+
.then((started) => {
|
|
203
|
+
server = started;
|
|
204
|
+
return started;
|
|
205
|
+
})
|
|
206
|
+
.finally(() => {
|
|
207
|
+
starting = undefined;
|
|
208
|
+
});
|
|
209
|
+
return starting;
|
|
192
210
|
};
|
|
193
211
|
|
|
194
212
|
/** Lists documents that were just opened: new ones get an id, known ones keep theirs. */
|
package/src/extension/index.ts
CHANGED
|
@@ -18,8 +18,7 @@ import {
|
|
|
18
18
|
import { showDocTool } from "./tool.ts";
|
|
19
19
|
|
|
20
20
|
export * from "./contract.ts";
|
|
21
|
-
export { createBetterShow, type Deps, defaultDeps } from "./controller.ts";
|
|
22
|
-
export { createPageServer } from "./server.ts";
|
|
21
|
+
export { createBetterShow, createPageServer, type Deps, defaultDeps } from "./controller.ts";
|
|
23
22
|
|
|
24
23
|
/** Set to `off` to stop a proposed Mini SDD spec from opening on its own. */
|
|
25
24
|
export const AUTO_OPEN_ENV = "PI_BETTER_SHOW_AUTO_OPEN";
|
package/src/extension/server.ts
CHANGED
|
@@ -100,6 +100,22 @@ const finish = (response: ServerResponse, status: number) => {
|
|
|
100
100
|
const titleOf = (markdown: string, fallback: string): string =>
|
|
101
101
|
/^#\s+(.+?)\s*#*\s*$/m.exec(markdown)?.[1]?.replace(/[*_`]/g, "") ?? fallback;
|
|
102
102
|
|
|
103
|
+
const HTML_ENTITIES: Record<string, string> = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: " " };
|
|
104
|
+
|
|
105
|
+
/** The `<title>` of an HTML page, as the text it shows, else the fallback. */
|
|
106
|
+
export function htmlTitleOf(html: string, fallback: string): string {
|
|
107
|
+
const raw = /<title[^>]*>([\s\S]*?)<\/title\s*>/i.exec(html)?.[1];
|
|
108
|
+
const text = raw
|
|
109
|
+
?.replace(/&#(\d+);|&#x([\da-f]+);|&(\w+);/gi, (whole, dec?: string, hex?: string, name?: string) => {
|
|
110
|
+
const code = dec ? Number(dec) : hex ? Number.parseInt(hex, 16) : undefined;
|
|
111
|
+
if (code === undefined) return HTML_ENTITIES[(name ?? "").toLowerCase()] ?? whole;
|
|
112
|
+
return code > 0 && code <= 0x10ffff ? String.fromCodePoint(code) : whole;
|
|
113
|
+
})
|
|
114
|
+
.replace(/\s+/g, " ")
|
|
115
|
+
.trim();
|
|
116
|
+
return text || fallback;
|
|
117
|
+
}
|
|
118
|
+
|
|
103
119
|
export function createPageServer(options: PageServerOptions): Promise<PageServer> {
|
|
104
120
|
const idleMs = options.idleMs ?? PAGE_IDLE_MS;
|
|
105
121
|
const prefix = `/${randomUUID()}`;
|
|
@@ -365,9 +381,11 @@ export function createPageServer(options: PageServerOptions): Promise<PageServer
|
|
|
365
381
|
}
|
|
366
382
|
if (HTML_FILE.test(path) || REACT_FILE.test(path)) {
|
|
367
383
|
const frame = `${framePrefix}${url.pathname.slice(filesPrefix.length)}`;
|
|
384
|
+
const source = content.toString("utf8");
|
|
368
385
|
const html = pageShell({
|
|
369
|
-
title
|
|
370
|
-
|
|
386
|
+
// The panel on this page names the document by it, as the page's own title would.
|
|
387
|
+
title: HTML_FILE.test(path) ? htmlTitleOf(source, basename(path)) : basename(path),
|
|
388
|
+
lang: langOf(source),
|
|
371
389
|
prefix,
|
|
372
390
|
body: `<iframe class="pbs-frame" title="${escapeHtml(basename(path))}" src="${escapeHtml(frame)}" sandbox="allow-scripts allow-forms"></iframe>`,
|
|
373
391
|
scripts: ["host.js"],
|
package/src/extension/tool.ts
CHANGED
|
@@ -18,12 +18,13 @@ export const DESCRIPTION =
|
|
|
18
18
|
"```checklist holds {title, submit, items: [string | {name, label, checked, note}]}, and the ticked items come back to you as a message; " +
|
|
19
19
|
"```table holds {columns: [string | {name, label, align, type: text|number|date}], rows: [[..] | {..}], sort, filter: true}: the user sorts by a column and filters by a text box; " +
|
|
20
20
|
"```steps holds {items: [{title, status: done|doing|todo|blocked, when, body}]}, a steps or timeline view; " +
|
|
21
|
-
"```stats holds a YAML list of {label, value, delta, tone, note} shown as metric tiles
|
|
21
|
+
"```stats holds a YAML list of {label, value, delta, tone, note} shown as metric tiles; " +
|
|
22
|
+
"```tree is a directory tree for structure reviews, shown with folders that collapse and expand: indented lines, two spaces per level, the first line the root, a folder's name ends with /, optional {tags} (new, changed, removed, focus, risk) then a note after ' # ' (e.g. ` core/ {focus} # parser and text`), and `… N more` for cut entries. Snapshot a workspace with `npx pbs-tree [dir]` (or `bunx pbs-tree`), which prints the fence and takes Linux tree's flags -L n, -d, -a, -I pattern, -P pattern, --dirsfirst, --filelimit n, --prune, plus --gitignore and --changed-since <rev> (tags new/changed/removed from git); keep it under a few hundred nodes (-L, -I, --gitignore), then add notes and tags by hand. body fields are Markdown. " +
|
|
22
23
|
"Images and links resolve against the page's directory; nothing loads from above it or from another site. " +
|
|
23
|
-
"Every Markdown page has a feedback panel: the user comments on selected passages and sends them to you as a message. " +
|
|
24
|
+
"Every Markdown, HTML, and TSX page has a feedback panel: the user comments on selected passages and sends them to you as a message. " +
|
|
24
25
|
"Put decisions that belong to the page (several questions, or a choice after a comparison) in a ```form at its end; ask a single short question with your question tool. " +
|
|
25
26
|
'An .html page runs as written under a sandbox (scripts and forms, no storage, nothing from other sites): a <form action="cgi-bin:pi-answer"> sends its fields to you when submitted, and piBetterShow.send(fields) does the same from a script. ' +
|
|
26
|
-
'When a page needs interaction (inputs that recompute, tabs, filters), write a .tsx or .jsx file and open it with view "page": React is built in, and the "pi-kit" module exports PbsBlock, PbsForm, PbsOptions, PbsReview, PbsChecklist, PbsTable, PbsCallout, PbsCards, PbsMindmap, PbsSuggest, PbsSteps, PbsStats, PbsDiff, PbsDiagram (props data, onAnswer; PbsBlock draws a parsed block), parse, encodeAnswer, and send(answer or fields) to hand you any values as a message. Import sibling modules freely; import no CSS. ' +
|
|
27
|
+
'When a page needs interaction (inputs that recompute, tabs, filters), write a .tsx or .jsx file and open it with view "page": React is built in, and the "pi-kit" module exports PbsBlock, PbsForm, PbsOptions, PbsReview, PbsChecklist, PbsTable, PbsCallout, PbsCards, PbsMindmap, PbsSuggest, PbsSteps, PbsStats, PbsDiff, PbsDiagram, PbsTree (props data, onAnswer; PbsBlock draws a parsed block), parse, encodeAnswer, and send(answer or fields) to hand you any values as a message. Import sibling modules freely; import no CSS. ' +
|
|
27
28
|
"It returns at once without waiting for the user. Pages reload and edited documents refresh when you change them.";
|
|
28
29
|
|
|
29
30
|
export const parameters = Type.Object({
|
|
@@ -47,6 +48,9 @@ export const showDocTool = (show: BetterShow) =>
|
|
|
47
48
|
label: "Show document",
|
|
48
49
|
description: DESCRIPTION,
|
|
49
50
|
parameters,
|
|
51
|
+
// pi runs the calls of one assistant message in parallel; a `write` issued beside this call would not have
|
|
52
|
+
// finished when it reads the file ("cannot read"). Sequential runs the calls in order, the write first.
|
|
53
|
+
executionMode: "sequential",
|
|
50
54
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
51
55
|
show.setContext(ctx);
|
|
52
56
|
const result = await show.show(ctx.cwd, params.paths, params.reason, params.view);
|
package/src/react/index.ts
CHANGED
|
@@ -24,6 +24,7 @@ import type {
|
|
|
24
24
|
StepsData,
|
|
25
25
|
SuggestData,
|
|
26
26
|
TableData,
|
|
27
|
+
TreeData,
|
|
27
28
|
} from "../core/types.ts";
|
|
28
29
|
import type { AnsweredFields, BlockRef, Density, PbsElement, Scheme, TAGS } from "../elements/index.ts";
|
|
29
30
|
import "../elements/index.ts";
|
|
@@ -124,6 +125,7 @@ export const PbsSteps = component<StepsData>("pbs-steps");
|
|
|
124
125
|
export const PbsStats = component<StatsData>("pbs-stats");
|
|
125
126
|
export const PbsDiff = component<DiffData>("pbs-diff");
|
|
126
127
|
export const PbsDiagram = component<MermaidData>("pbs-diagram");
|
|
128
|
+
export const PbsTree = component<TreeData>("pbs-tree");
|
|
127
129
|
|
|
128
130
|
const BY_KIND: { [K in keyof typeof TAGS]: (props: PbsProps<BlockDataMap[K]>) => ReactElement } = {
|
|
129
131
|
alert: PbsCallout,
|
|
@@ -139,6 +141,7 @@ const BY_KIND: { [K in keyof typeof TAGS]: (props: PbsProps<BlockDataMap[K]>) =>
|
|
|
139
141
|
stats: PbsStats,
|
|
140
142
|
diff: PbsDiff,
|
|
141
143
|
mermaid: PbsDiagram,
|
|
144
|
+
tree: PbsTree,
|
|
142
145
|
};
|
|
143
146
|
|
|
144
147
|
export interface PbsBlockProps extends Omit<PbsProps<never>, "data" | "blockRef" | "ref"> {
|