@agent-native/core 0.49.24 → 0.49.26
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/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +8 -1
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/cli/recap.d.ts.map +1 -1
- package/dist/cli/recap.js +43 -11
- package/dist/cli/recap.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +2 -1
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/blocks/library/AnnotatedCodeBlock.js +7 -7
- package/dist/client/blocks/library/AnnotatedCodeBlock.js.map +1 -1
- package/dist/client/blocks/library/DiffBlock.js +3 -3
- package/dist/client/blocks/library/DiffBlock.js.map +1 -1
- package/dist/client/blocks/library/annotation-rail.d.ts +4 -3
- package/dist/client/blocks/library/annotation-rail.d.ts.map +1 -1
- package/dist/client/blocks/library/annotation-rail.js +16 -9
- package/dist/client/blocks/library/annotation-rail.js.map +1 -1
- package/dist/client/blocks/types.d.ts +2 -2
- package/dist/client/blocks/types.js.map +1 -1
- package/dist/coding-tools/run-code.d.ts.map +1 -1
- package/dist/coding-tools/run-code.js +198 -15
- package/dist/coding-tools/run-code.js.map +1 -1
- package/dist/extensions/fetch-tool.js +1 -1
- package/dist/extensions/fetch-tool.js.map +1 -1
- package/dist/mcp/build-server.d.ts.map +1 -1
- package/dist/mcp/build-server.js +1 -0
- package/dist/mcp/build-server.js.map +1 -1
- package/dist/mcp/builtin-tools.d.ts +8 -4
- package/dist/mcp/builtin-tools.d.ts.map +1 -1
- package/dist/mcp/builtin-tools.js +247 -13
- package/dist/mcp/builtin-tools.js.map +1 -1
- package/dist/provider-api/actions/query-staged-dataset.d.ts.map +1 -1
- package/dist/provider-api/actions/query-staged-dataset.js +1 -0
- package/dist/provider-api/actions/query-staged-dataset.js.map +1 -1
- package/dist/provider-api/index.d.ts +15 -4
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/provider-api/index.js +191 -43
- package/dist/provider-api/index.js.map +1 -1
- package/dist/provider-api/staged-datasets-store.d.ts.map +1 -1
- package/dist/provider-api/staged-datasets-store.js +29 -6
- package/dist/provider-api/staged-datasets-store.js.map +1 -1
- package/dist/provider-api/staging.d.ts +6 -1
- package/dist/provider-api/staging.d.ts.map +1 -1
- package/dist/provider-api/staging.js +35 -6
- package/dist/provider-api/staging.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +157 -80
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/prompts/shared-rules.d.ts +1 -1
- package/dist/server/prompts/shared-rules.d.ts.map +1 -1
- package/dist/server/prompts/shared-rules.js +5 -7
- package/dist/server/prompts/shared-rules.js.map +1 -1
- package/dist/server/schema-prompt.js +1 -1
- package/dist/server/schema-prompt.js.map +1 -1
- package/dist/templates/default/.agents/skills/actions/SKILL.md +37 -9
- package/dist/templates/default/.agents/skills/adding-a-feature/SKILL.md +7 -1
- package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +37 -9
- package/dist/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +7 -1
- package/package.json +1 -1
- package/src/templates/default/.agents/skills/actions/SKILL.md +37 -9
- package/src/templates/default/.agents/skills/adding-a-feature/SKILL.md +7 -1
- package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +37 -9
- package/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +7 -1
|
@@ -105,9 +105,9 @@ export function AnnotationGutterMarker({ marker, active, className, }) {
|
|
|
105
105
|
* by the visually-hidden a11y/test stack and by the on-hover portal popover.
|
|
106
106
|
*/
|
|
107
107
|
export function AnnotationCard({ item, ctx, active = false, showMarker = false, className, onMouseEnter, onMouseLeave, }) {
|
|
108
|
-
return (_jsxs("div", { onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, className: cn("rounded-lg border px-3.5 py-2.5 shadow-lg shadow-black/10 backdrop-blur-
|
|
109
|
-
? "border-yellow-300/
|
|
110
|
-
: "border-plan-line bg-plan-block hover:border-yellow-300/45", className), children: [_jsxs("div", { className: cn("flex flex-wrap gap-x-2 gap-y-
|
|
108
|
+
return (_jsxs("div", { onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, className: cn("rounded-lg border px-3.5 py-2.5 shadow-lg shadow-black/10 backdrop-blur-xl transition-colors dark:shadow-black/40", active
|
|
109
|
+
? "border-yellow-300/55 bg-yellow-50/80 dark:border-yellow-200/25 dark:bg-yellow-300/[0.10]"
|
|
110
|
+
: "border-plan-line bg-plan-block hover:border-yellow-300/45", className), children: [_jsxs("div", { className: cn("flex min-w-0 flex-wrap gap-x-2 gap-y-1", showMarker ? "items-center" : "items-baseline"), children: [showMarker && (_jsx(AnnotationGutterMarker, { marker: item.marker, active: active })), _jsx("span", { className: "shrink-0 text-[11px] font-semibold uppercase tracking-wide text-plan-muted", children: rangeLabel(item) }), item.annotation.label && (_jsx("span", { className: "min-w-0 max-w-full flex-1 break-words text-[13px] font-semibold leading-snug text-plan-text [overflow-wrap:anywhere]", children: item.annotation.label }))] }), _jsx("div", { className: "plan-annotation-note mt-1 break-words text-[13px] leading-relaxed text-plan-text/85 [overflow-wrap:anywhere]", children: ctx.renderMarkdown ? (ctx.renderMarkdown(item.annotation.note)) : (_jsx("p", { children: item.annotation.note })) })] }));
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
113
|
* Visually-hidden stack of every resolved note. It is NOT a visible column — it
|
|
@@ -220,12 +220,13 @@ export function AnnotationInlineOverlayStack({ items, ctx, showMarker = false, c
|
|
|
220
220
|
};
|
|
221
221
|
const portal = typeof document === "undefined"
|
|
222
222
|
? null
|
|
223
|
-
: createPortal(_jsx("div", { "aria-hidden": true, ref: portalRef, "data-annotation-inline-overlay": true, "data-annotation-inline-overlay-mode": mode, "data-annotation-inline-overlay-side": position?.kind === "margin" ? position.side : "right", className: cn("pointer-events-none z-50 flex w-[min(20rem,45vw)] flex-col gap-2", mode === "capture" ? "absolute" : "fixed"), style: portalStyle, children: resolved.map((item) => (_jsx(AnnotationCard, { item: item, ctx: ctx, active: true, showMarker: showMarker, className: "border-yellow-300/
|
|
223
|
+
: createPortal(_jsx("div", { "aria-hidden": true, ref: portalRef, "data-annotation-inline-overlay": true, "data-annotation-inline-overlay-mode": mode, "data-annotation-inline-overlay-side": position?.kind === "margin" ? position.side : "right", className: cn("pointer-events-none z-50 flex w-[min(20rem,45vw)] flex-col gap-2", mode === "capture" ? "absolute" : "fixed"), style: portalStyle, children: resolved.map((item) => (_jsx(AnnotationCard, { item: item, ctx: ctx, active: true, showMarker: showMarker, className: "border-yellow-300/55 bg-yellow-50/80 shadow-lg shadow-black/10 backdrop-blur-xl dark:border-yellow-200/25 dark:bg-yellow-300/[0.10] dark:shadow-black/50" }, item.index))) }), document.body);
|
|
224
224
|
return (_jsxs(_Fragment, { children: [_jsx("div", { "aria-hidden": true, ref: anchorRef, "data-annotation-inline-overlay-anchor": true, className: "pointer-events-none absolute right-3 top-0 z-20 h-0 w-0 overflow-visible" }), portal] }));
|
|
225
225
|
}
|
|
226
226
|
const HOVER_CARD_WIDTH = 280;
|
|
227
227
|
const INLINE_OVERLAY_WIDTH = 320;
|
|
228
228
|
const HOVER_CARD_GAP = 12;
|
|
229
|
+
const HOVER_CARD_OVERHANG = 40;
|
|
229
230
|
const VIEWPORT_MARGIN = 8;
|
|
230
231
|
const SCROLL_HOVER_SUPPRESS_MS = 260;
|
|
231
232
|
function oppositeSide(side) {
|
|
@@ -247,6 +248,11 @@ function hoverCardLeftForSide(side, anchor, cardWidth) {
|
|
|
247
248
|
? anchor.codeRight + HOVER_CARD_GAP
|
|
248
249
|
: anchor.codeLeft - HOVER_CARD_GAP - cardWidth;
|
|
249
250
|
}
|
|
251
|
+
function hoverCardOverlapLeftForSide(side, anchor, cardWidth) {
|
|
252
|
+
return side === "right"
|
|
253
|
+
? anchor.codeRight - cardWidth + HOVER_CARD_OVERHANG
|
|
254
|
+
: anchor.codeLeft - HOVER_CARD_OVERHANG;
|
|
255
|
+
}
|
|
250
256
|
function hoverCardFitsSide(side, anchor, cardWidth, viewportWidth) {
|
|
251
257
|
const left = hoverCardLeftForSide(side, anchor, cardWidth);
|
|
252
258
|
return (left >= VIEWPORT_MARGIN &&
|
|
@@ -297,7 +303,7 @@ export function resolveAnnotationMarginOverlayPosition(anchor, card, viewport, o
|
|
|
297
303
|
}
|
|
298
304
|
export function resolveAnnotationHoverCardPosition(anchor, card, viewport, options = {}) {
|
|
299
305
|
const preferredSide = options.preferredSide ?? "right";
|
|
300
|
-
const hoverFallbackSide = options.hoverFallbackSide ?? "
|
|
306
|
+
const hoverFallbackSide = options.hoverFallbackSide ?? "right";
|
|
301
307
|
const allowOppositeSideFallback = options.allowOppositeSideFallback ?? true;
|
|
302
308
|
const opposite = oppositeSide(preferredSide);
|
|
303
309
|
let left;
|
|
@@ -312,7 +318,7 @@ export function resolveAnnotationHoverCardPosition(anchor, card, viewport, optio
|
|
|
312
318
|
top = anchor.lineCenter - card.height / 2;
|
|
313
319
|
}
|
|
314
320
|
else if (hoverFallbackSide === "left" || hoverFallbackSide === "right") {
|
|
315
|
-
left =
|
|
321
|
+
left = hoverCardOverlapLeftForSide(hoverFallbackSide, anchor, card.width);
|
|
316
322
|
top = anchor.lineCenter - card.height / 2;
|
|
317
323
|
}
|
|
318
324
|
else {
|
|
@@ -379,9 +385,10 @@ export function useAnnotationMarginNotesAvailable({ containerRef, enabled, side
|
|
|
379
385
|
* vertically centered on the hovered line — so it never overlaps the code text.
|
|
380
386
|
* If there isn't room to the right, it uses the LEFT of the code block when the
|
|
381
387
|
* card can fit there without covering code. Only when neither side fits does it
|
|
382
|
-
*
|
|
383
|
-
*
|
|
384
|
-
*
|
|
388
|
+
* overlap the code from the RIGHT edge with a small overhang, so the hover still
|
|
389
|
+
* reads as an attached overlay instead of a left-aligned card. The card keeps
|
|
390
|
+
* itself open while hovered (`onMouseEnter`/`onMouseLeave` forwarded) so it stays
|
|
391
|
+
* readable; the caller adds the small hover-intent close delay.
|
|
385
392
|
*/
|
|
386
393
|
export function AnnotationHoverCard({ item, anchor, ctx, showMarker = false, preferredSide, hoverFallbackSide, onMouseEnter, onMouseLeave, onClose, }) {
|
|
387
394
|
const cardRef = useRef(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotation-rail.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/annotation-rail.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GAIT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAGpC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,kFAAkF;AAElF;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAW,EACX,SAAiB;IAEjB,MAAM,KAAK,GAAG,gCAAgC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,IAAI,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC1C,IAAI,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACnE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAClE,IAAI,KAAK,GAAG,GAAG;QAA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AE,UAAU,EACtB,YAAY,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,EAC9C,YAAY,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,IANnC,IAAI,CAAC,KAAK,CAOf,CACH,CAAC,GACE,CACP,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,kBAAkB,CAAC,KAA2B;IAC5D,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import {\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type RefObject,\n type ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../../utils.js\";\nimport type { BlockRenderContext } from \"../types.js\";\n\n/**\n * Shared line-anchored annotation UI for the `annotated-code` and `diff` blocks.\n *\n * Both blocks render a numbered code surface plus a side \"rail\" of notes, where\n * each note targets a 1-based `lines` ref (`\"3\"` or `\"3-5\"`) and hovering a code\n * line ↔ its note cross-highlights. This module owns the pure pieces that were\n * identical between them so neither block forks the behavior:\n *\n * - `parseLineRange` — the forgiving 1-based `lines` range parser.\n * - `resolveAnnotations` / `buildLineMarkerMap` — turn a raw annotation list\n * into stable, marker-numbered, range-resolved records and a line→markers map.\n * - `rangeLabel` — the human \"Line 8\" / \"Lines 3–6\" label.\n * - `AnnotationGutterMarker` — the numbered amber pip placed on an annotated row\n * (used by the diff grid; the annotated-code surface uses its own rail bar).\n * - `AnnotationNoteRail` — the responsive list of note cards with two-way hover.\n * `showMarker` opts the diff block into a leading numbered pip on each card so\n * a note can be matched to its `①`/`②` row marker; annotated-code omits it to\n * keep its original card chrome.\n *\n * `AnnotatedCodeBlock` annotates a single code surface; `DiffBlock` annotates a\n * before/after grid (each annotation also carries a `side`). The shared types\n * here are intentionally minimal — callers pass their own `side` handling and\n * decide which rows a marker lands on; this module only owns the parsing, the\n * resolved-record shape, and the rendered marker + rail chrome.\n */\n\n/* ── Line-ref parsing ──────────────────────────────────────────────────────── */\n\n/**\n * Parse a 1-based `lines` ref (`\"3\"` or `\"3-5\"`) into an inclusive `[start,end]`\n * pair, clamped to `[1, lineCount]`. Returns `null` for malformed or fully\n * out-of-range refs so callers can ignore them gracefully. A reversed range\n * (`\"5-3\"`) is normalized; a partially out-of-range range is clamped.\n */\nexport function parseLineRange(\n ref: string,\n lineCount: number,\n): { start: number; end: number } | null {\n const match = /^\\s*(\\d+)\\s*(?:-\\s*(\\d+)\\s*)?$/.exec(ref);\n if (!match) return null;\n let start = Number.parseInt(match[1], 10);\n let end = match[2] != null ? Number.parseInt(match[2], 10) : start;\n if (!Number.isFinite(start) || !Number.isFinite(end)) return null;\n if (start > end) [start, end] = [end, start];\n // Fully outside the file → ignore.\n if (end < 1 || start > lineCount) return null;\n return { start: Math.max(1, start), end: Math.min(lineCount, end) };\n}\n\n/** The minimal annotation shape the rail needs (a superset works too). */\nexport interface RailAnnotation {\n lines: string;\n label?: string;\n note: string;\n}\n\nexport interface ResolvedAnnotation<A extends RailAnnotation = RailAnnotation> {\n /** Index in the original `annotations` array (stable hover key). */\n index: number;\n /** 1-based marker number (authoring order). */\n marker: number;\n annotation: A;\n range: { start: number; end: number } | null;\n}\n\n/**\n * Resolve a raw annotation list into stable, marker-numbered records, parsing\n * each `lines` ref against `lineCount`. `lineCountFor` lets the diff block pick a\n * per-annotation line count (before-side vs after-side); annotated-code passes a\n * single constant. Markers are authoring-order, 1-based, and assigned to ALL\n * annotations (even unresolved ones) so numbering is stable regardless of which\n * refs happen to match.\n */\nexport function resolveAnnotations<A extends RailAnnotation>(\n annotations: A[] | undefined,\n lineCountFor: (annotation: A) => number,\n): ResolvedAnnotation<A>[] {\n return (annotations ?? []).map((annotation, index) => ({\n index,\n marker: index + 1,\n annotation,\n range: parseLineRange(annotation.lines, lineCountFor(annotation)),\n }));\n}\n\n/** Map a 1-based line number → the resolved annotations covering it. */\nexport function buildLineMarkerMap<A extends RailAnnotation>(\n resolved: ResolvedAnnotation<A>[],\n): Map<number, ResolvedAnnotation<A>[]> {\n const map = new Map<number, ResolvedAnnotation<A>[]>();\n for (const item of resolved) {\n if (!item.range) continue;\n for (let n = item.range.start; n <= item.range.end; n += 1) {\n const list = map.get(n) ?? [];\n list.push(item);\n map.set(n, list);\n }\n }\n return map;\n}\n\n/** Human label for a resolved annotation's line span (\"Line 8\" / \"Lines 3–6\"). */\nexport function rangeLabel(item: ResolvedAnnotation): string {\n if (!item.range) return `Lines ${item.annotation.lines}`;\n return item.range.start === item.range.end\n ? `Line ${item.range.start}`\n : `Lines ${item.range.start}–${item.range.end}`;\n}\n\n/* ── Marker ────────────────────────────────────────────────────────────────── */\n\n/**\n * The numbered amber pip rendered on an annotated code row's gutter. `active`\n * brightens it when its note (or a co-located row) is hovered.\n */\nexport function AnnotationGutterMarker({\n marker,\n active,\n className,\n}: {\n marker: number;\n active: boolean;\n className?: string;\n}) {\n return (\n <span\n aria-hidden\n className={cn(\n \"inline-flex size-[15px] shrink-0 items-center justify-center rounded-full text-[9px] font-semibold leading-none tabular-nums transition-colors\",\n active\n ? \"bg-yellow-400 text-yellow-950 dark:bg-yellow-300 dark:text-yellow-950\"\n : \"bg-yellow-300/25 text-yellow-800 dark:bg-yellow-300/16 dark:text-yellow-200\",\n className,\n )}\n >\n {marker}\n </span>\n );\n}\n\n/* ── Note card ─────────────────────────────────────────────────────────────── */\n\n/**\n * One line-anchored note card: marker pip (when `showMarker`), the resolved line\n * span (\"Line 8\"), an optional label, and the markdown `note` (via\n * `ctx.renderMarkdown`). This is the single source of card markup, rendered both\n * by the visually-hidden a11y/test stack and by the on-hover portal popover.\n */\nexport function AnnotationCard<A extends RailAnnotation>({\n item,\n ctx,\n active = false,\n showMarker = false,\n className,\n onMouseEnter,\n onMouseLeave,\n}: {\n item: ResolvedAnnotation<A>;\n ctx: BlockRenderContext;\n active?: boolean;\n showMarker?: boolean;\n className?: string;\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n}) {\n return (\n <div\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n className={cn(\n \"rounded-lg border px-3.5 py-2.5 shadow-lg shadow-black/10 backdrop-blur-md transition-colors dark:shadow-black/40\",\n active\n ? \"border-yellow-300/80 bg-yellow-50/95 dark:border-yellow-200/35 dark:bg-yellow-300/16\"\n : \"border-plan-line bg-plan-block hover:border-yellow-300/45\",\n className,\n )}\n >\n <div\n className={cn(\n \"flex flex-wrap gap-x-2 gap-y-0.5\",\n showMarker ? \"items-center\" : \"items-baseline\",\n )}\n >\n {showMarker && (\n <AnnotationGutterMarker marker={item.marker} active={active} />\n )}\n <span className=\"text-[11px] font-semibold uppercase tracking-wide text-plan-muted\">\n {rangeLabel(item)}\n </span>\n {item.annotation.label && (\n <span className=\"text-[13px] font-semibold text-plan-text\">\n {item.annotation.label}\n </span>\n )}\n </div>\n <div className=\"plan-annotation-note mt-1 text-[13px] leading-relaxed text-plan-text/85\">\n {ctx.renderMarkdown ? (\n ctx.renderMarkdown(item.annotation.note)\n ) : (\n <p>{item.annotation.note}</p>\n )}\n </div>\n </div>\n );\n}\n\n/**\n * Visually-hidden stack of every resolved note. It is NOT a visible column — it\n * sits in the flow but clipped to a 1px box (the `sr-only` pattern) so the note\n * text and the per-card marker pips stay in the accessibility tree and in the\n * DOM (assistive tech can reach them, and tests that read `textContent`/count\n * pips still see them) WITHOUT painting a persistent rail beside the code. The\n * visible card appears only on hover via {@link AnnotationHoverCard}.\n */\nexport function AnnotationHiddenStack<A extends RailAnnotation>({\n items,\n ctx,\n showMarker = false,\n}: {\n items: ResolvedAnnotation<A>[];\n ctx: BlockRenderContext;\n showMarker?: boolean;\n}) {\n const resolved = useMemo(() => items.filter((item) => item.range), [items]);\n if (resolved.length === 0) return null;\n return (\n <div\n className=\"absolute size-px overflow-hidden whitespace-nowrap border-0 p-0 [clip:rect(0,0,0,0)] [clip-path:inset(50%)]\"\n data-annotation-hidden-stack\n >\n {resolved.map((item) => (\n <AnnotationCard\n key={item.index}\n item={item}\n ctx={ctx}\n showMarker={showMarker}\n />\n ))}\n </div>\n );\n}\n\nexport function AnnotationInlineOverlayStack<A extends RailAnnotation>({\n items,\n ctx,\n showMarker = false,\n containerRef,\n mode = \"capture\",\n side = \"right\",\n preferredSide = \"right\",\n}: {\n items: ResolvedAnnotation<A>[];\n ctx: BlockRenderContext;\n showMarker?: boolean;\n containerRef?: RefObject<HTMLElement | null>;\n mode?: \"capture\" | \"margin\";\n side?: AnnotationMarginSide;\n preferredSide?: AnnotationSide;\n}) {\n const resolved = items.filter((item) => item.range);\n const anchorRef = useRef<HTMLDivElement | null>(null);\n const portalRef = useRef<HTMLDivElement | null>(null);\n const [position, setPosition] = useState<\n | { kind: \"capture\"; top: number; left: number; visible: boolean }\n | {\n kind: \"margin\";\n top: number;\n left: number;\n visible: boolean;\n side: AnnotationSide;\n }\n | null\n >(null);\n const positionKey = resolved\n .map(\n (item) =>\n `${item.index}:${item.marker}:${item.annotation.lines}:${item.annotation.label ?? \"\"}:${item.annotation.note}`,\n )\n .join(\"|\");\n\n useLayoutEffect(() => {\n if (typeof window === \"undefined\") return;\n const anchor = anchorRef.current;\n if (!anchor) return;\n\n let frame: number | null = null;\n const updatePosition = () => {\n frame = null;\n const anchorRect = anchor.getBoundingClientRect();\n const portalRect = portalRef.current?.getBoundingClientRect();\n const viewportWidth = Math.max(\n window.innerWidth || 0,\n INLINE_OVERLAY_WIDTH + VIEWPORT_MARGIN * 2,\n );\n const viewportHeight = Math.max(\n window.innerHeight || 0,\n VIEWPORT_MARGIN * 2,\n );\n const width =\n portalRect && portalRect.width > 0\n ? portalRect.width\n : Math.min(INLINE_OVERLAY_WIDTH, viewportWidth * 0.45);\n const height =\n portalRect && portalRect.height > 0 ? portalRect.height : 0;\n if (mode === \"margin\") {\n const containerRect =\n containerRef?.current?.getBoundingClientRect() ?? anchorRect;\n const next = resolveAnnotationMarginOverlayPosition(\n {\n left: containerRect.left,\n right: containerRect.right,\n top: anchorRect.top,\n height: anchorRect.height,\n },\n { width, height },\n { width: viewportWidth, height: viewportHeight },\n { side, preferredSide },\n );\n setPosition({ kind: \"margin\", ...next });\n return;\n }\n const scroll = {\n x: window.scrollX || window.pageXOffset || 0,\n y: window.scrollY || window.pageYOffset || 0,\n };\n setPosition({\n kind: \"capture\",\n visible: Boolean(portalRect && portalRect.height > 0),\n ...resolveAnnotationCaptureOverlayPosition(\n {\n right: anchorRect.right,\n top: anchorRect.top,\n height: anchorRect.height,\n },\n { width, height },\n { width: viewportWidth, height: viewportHeight },\n scroll,\n ),\n });\n };\n const scheduleUpdatePosition = () => {\n if (frame != null) return;\n if (typeof window.requestAnimationFrame === \"function\") {\n frame = window.requestAnimationFrame(updatePosition);\n return;\n }\n updatePosition();\n };\n\n updatePosition();\n scheduleUpdatePosition();\n window.addEventListener(\"resize\", updatePosition);\n window.addEventListener(\"scroll\", scheduleUpdatePosition, {\n capture: true,\n passive: true,\n });\n return () => {\n if (frame != null && typeof window.cancelAnimationFrame === \"function\") {\n window.cancelAnimationFrame(frame);\n }\n window.removeEventListener(\"resize\", updatePosition);\n window.removeEventListener(\"scroll\", scheduleUpdatePosition, {\n capture: true,\n });\n };\n }, [containerRef, mode, positionKey, preferredSide, side]);\n\n if (resolved.length === 0) return null;\n\n const portalStyle: CSSProperties =\n position?.kind === \"margin\"\n ? {\n top: position.top,\n left: position.left,\n visibility:\n position.visible && position\n ? (\"visible\" as const)\n : (\"hidden\" as const),\n }\n : {\n top: position?.top ?? VIEWPORT_MARGIN,\n left:\n position && position.kind === \"capture\"\n ? position.left\n : VIEWPORT_MARGIN,\n visibility:\n position?.kind === \"capture\" && position.visible\n ? (\"visible\" as const)\n : (\"hidden\" as const),\n };\n\n const portal =\n typeof document === \"undefined\"\n ? null\n : createPortal(\n <div\n aria-hidden\n ref={portalRef}\n data-annotation-inline-overlay\n data-annotation-inline-overlay-mode={mode}\n data-annotation-inline-overlay-side={\n position?.kind === \"margin\" ? position.side : \"right\"\n }\n className={cn(\n \"pointer-events-none z-50 flex w-[min(20rem,45vw)] flex-col gap-2\",\n mode === \"capture\" ? \"absolute\" : \"fixed\",\n )}\n style={portalStyle}\n >\n {resolved.map((item) => (\n <AnnotationCard\n key={item.index}\n item={item}\n ctx={ctx}\n active\n showMarker={showMarker}\n className=\"border-yellow-300/80 bg-yellow-50/95 shadow-lg shadow-black/10 backdrop-blur-md dark:border-yellow-200/35 dark:bg-yellow-300/16 dark:shadow-black/50\"\n />\n ))}\n </div>,\n document.body,\n );\n\n return (\n <>\n <div\n aria-hidden\n ref={anchorRef}\n data-annotation-inline-overlay-anchor\n className=\"pointer-events-none absolute right-3 top-0 z-20 h-0 w-0 overflow-visible\"\n />\n {portal}\n </>\n );\n}\n\n/* ── Hover popover (portal, anchored beside the code) ──────────────────────── */\n\n/** The geometry the hover card anchors to (in viewport coordinates). */\nexport interface AnnotationAnchor {\n /** Right edge of the code block (where the card should start). */\n codeRight: number;\n /** Left edge of the code block (for the below-fallback alignment). */\n codeLeft: number;\n /** Vertical center of the hovered line. */\n lineCenter: number;\n /** Bottom of the hovered line (for the below-fallback placement). */\n lineBottom: number;\n}\n\nexport type AnnotationSide = \"left\" | \"right\";\nexport type AnnotationMarginSide = AnnotationSide | \"auto\";\n\nconst HOVER_CARD_WIDTH = 280;\nconst INLINE_OVERLAY_WIDTH = 320;\nconst HOVER_CARD_GAP = 12;\nconst VIEWPORT_MARGIN = 8;\nconst SCROLL_HOVER_SUPPRESS_MS = 260;\n\nfunction oppositeSide(side: AnnotationSide): AnnotationSide {\n return side === \"left\" ? \"right\" : \"left\";\n}\n\nfunction clampWithinViewport(\n value: number,\n size: number,\n viewportSize: number,\n): number {\n return Math.max(\n VIEWPORT_MARGIN,\n Math.min(value, viewportSize - size - VIEWPORT_MARGIN),\n );\n}\n\nfunction centeredTop(\n anchor: { top: number; height: number },\n cardHeight: number,\n viewportHeight: number,\n): number {\n const maxTop = Math.max(\n VIEWPORT_MARGIN,\n viewportHeight - cardHeight - VIEWPORT_MARGIN,\n );\n const raw = anchor.top + anchor.height / 2 - cardHeight / 2;\n return Math.max(VIEWPORT_MARGIN, Math.min(raw, maxTop));\n}\n\nfunction inlineOverlayWidthForViewport(viewportWidth: number): number {\n return Math.min(INLINE_OVERLAY_WIDTH, Math.max(0, viewportWidth * 0.45));\n}\n\nfunction hoverCardLeftForSide(\n side: AnnotationSide,\n anchor: AnnotationAnchor,\n cardWidth: number,\n): number {\n return side === \"right\"\n ? anchor.codeRight + HOVER_CARD_GAP\n : anchor.codeLeft - HOVER_CARD_GAP - cardWidth;\n}\n\nfunction hoverCardFitsSide(\n side: AnnotationSide,\n anchor: AnnotationAnchor,\n cardWidth: number,\n viewportWidth: number,\n): boolean {\n const left = hoverCardLeftForSide(side, anchor, cardWidth);\n return (\n left >= VIEWPORT_MARGIN &&\n left + cardWidth + VIEWPORT_MARGIN <= viewportWidth\n );\n}\n\nexport function resolveAnnotationInlineOverlayPosition(\n anchor: { right: number; top: number; height: number },\n card: { width: number; height: number },\n viewport: { width: number; height: number },\n): { top: number; right: number } {\n const maxRight = Math.max(\n VIEWPORT_MARGIN,\n viewport.width - card.width - VIEWPORT_MARGIN,\n );\n\n return {\n top: centeredTop(anchor, card.height, viewport.height),\n right: Math.max(\n VIEWPORT_MARGIN,\n Math.min(viewport.width - anchor.right, maxRight),\n ),\n };\n}\n\nexport function resolveAnnotationCaptureOverlayPosition(\n anchor: { right: number; top: number; height: number },\n card: { width: number; height: number },\n viewport: { width: number; height: number },\n scroll: { x: number; y: number } = { x: 0, y: 0 },\n): { top: number; left: number } {\n const { right } = resolveAnnotationInlineOverlayPosition(\n anchor,\n card,\n viewport,\n );\n const left = scroll.x + viewport.width - right - card.width;\n const rawTop = anchor.top + anchor.height / 2 - card.height / 2;\n return {\n top: Math.max(scroll.y + VIEWPORT_MARGIN, scroll.y + rawTop),\n left,\n };\n}\n\nexport function resolveAnnotationMarginOverlayPosition(\n anchor: { left: number; right: number; top: number; height: number },\n card: { width: number; height: number },\n viewport: { width: number; height: number },\n options: {\n side?: AnnotationMarginSide;\n preferredSide?: AnnotationSide;\n } = {},\n): { top: number; left: number; visible: boolean; side: AnnotationSide } {\n const preferredSide = options.preferredSide ?? \"left\";\n const requestedSide = options.side ?? preferredSide;\n const sides: AnnotationSide[] =\n requestedSide === \"auto\"\n ? [preferredSide, oppositeSide(preferredSide)]\n : [requestedSide];\n const top = centeredTop(anchor, card.height, viewport.height);\n\n for (const candidate of sides) {\n const left =\n candidate === \"left\"\n ? anchor.left - HOVER_CARD_GAP - card.width\n : anchor.right + HOVER_CARD_GAP;\n const fits =\n left >= VIEWPORT_MARGIN &&\n left + card.width + VIEWPORT_MARGIN <= viewport.width;\n if (fits) return { top, left, visible: true, side: candidate };\n }\n\n const fallbackSide = requestedSide === \"auto\" ? preferredSide : requestedSide;\n const fallbackLeft =\n fallbackSide === \"left\"\n ? anchor.left - HOVER_CARD_GAP - card.width\n : anchor.right + HOVER_CARD_GAP;\n return {\n top,\n left: clampWithinViewport(fallbackLeft, card.width, viewport.width),\n visible: false,\n side: fallbackSide,\n };\n}\n\nexport function resolveAnnotationHoverCardPosition(\n anchor: AnnotationAnchor,\n card: { width: number; height: number },\n viewport: { width: number; height: number },\n options: {\n preferredSide?: AnnotationSide;\n hoverFallbackSide?: AnnotationSide | \"below\";\n allowOppositeSideFallback?: boolean;\n } = {},\n): { top: number; left: number } {\n const preferredSide = options.preferredSide ?? \"right\";\n const hoverFallbackSide = options.hoverFallbackSide ?? \"below\";\n const allowOppositeSideFallback = options.allowOppositeSideFallback ?? true;\n const opposite = oppositeSide(preferredSide);\n\n let left: number;\n let top: number;\n if (hoverCardFitsSide(preferredSide, anchor, card.width, viewport.width)) {\n left = hoverCardLeftForSide(preferredSide, anchor, card.width);\n top = anchor.lineCenter - card.height / 2;\n } else if (\n allowOppositeSideFallback &&\n hoverCardFitsSide(opposite, anchor, card.width, viewport.width)\n ) {\n left = hoverCardLeftForSide(opposite, anchor, card.width);\n top = anchor.lineCenter - card.height / 2;\n } else if (hoverFallbackSide === \"left\" || hoverFallbackSide === \"right\") {\n left = hoverCardLeftForSide(hoverFallbackSide, anchor, card.width);\n top = anchor.lineCenter - card.height / 2;\n } else {\n // No clean side gutter → drop below the line, aligned to the code's left.\n left = anchor.codeLeft;\n top = anchor.lineBottom + HOVER_CARD_GAP;\n }\n\n // Clamp within the viewport so the card is never cut off.\n left = clampWithinViewport(left, card.width, viewport.width);\n top = Math.max(\n VIEWPORT_MARGIN,\n Math.min(top, viewport.height - card.height - VIEWPORT_MARGIN),\n );\n\n return { top, left };\n}\n\nexport function useAnnotationMarginNotesAvailable({\n containerRef,\n enabled,\n side = \"auto\",\n preferredSide = \"left\",\n}: {\n containerRef: RefObject<HTMLElement | null>;\n enabled: boolean;\n side?: AnnotationMarginSide;\n preferredSide?: AnnotationSide;\n}) {\n const [available, setAvailable] = useState(false);\n\n useLayoutEffect(() => {\n if (!enabled || typeof window === \"undefined\") {\n setAvailable(false);\n return;\n }\n\n const update = () => {\n const element = containerRef.current;\n if (!element) {\n setAvailable(false);\n return;\n }\n const rect = element.getBoundingClientRect();\n const viewportWidth = Math.max(window.innerWidth || 0, 0);\n const cardWidth = inlineOverlayWidthForViewport(viewportWidth);\n const leftFits =\n rect.left - HOVER_CARD_GAP - cardWidth >= VIEWPORT_MARGIN;\n const rightFits =\n rect.right + HOVER_CARD_GAP + cardWidth + VIEWPORT_MARGIN <=\n viewportWidth;\n const next =\n side === \"left\"\n ? leftFits\n : side === \"right\"\n ? rightFits\n : preferredSide === \"left\"\n ? leftFits || rightFits\n : rightFits || leftFits;\n setAvailable(next);\n };\n\n update();\n const frame =\n typeof window.requestAnimationFrame === \"function\"\n ? window.requestAnimationFrame(update)\n : null;\n const observer =\n typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(update) : null;\n if (containerRef.current && observer)\n observer.observe(containerRef.current);\n window.addEventListener(\"resize\", update);\n return () => {\n if (frame != null && typeof window.cancelAnimationFrame === \"function\") {\n window.cancelAnimationFrame(frame);\n }\n observer?.disconnect();\n window.removeEventListener(\"resize\", update);\n };\n }, [containerRef, enabled, preferredSide, side]);\n\n return available;\n}\n\n/**\n * The single on-hover note card, portaled to `document.body` and positioned\n * `fixed` so it escapes the code block's `overflow` and never reflows the code.\n *\n * Placement: by default it sits to the RIGHT of the code block's right edge,\n * vertically centered on the hovered line — so it never overlaps the code text.\n * If there isn't room to the right, it uses the LEFT of the code block when the\n * card can fit there without covering code. Only when neither side fits does it\n * fall back to BELOW the hovered line (left-aligned to the code block). The card\n * keeps itself open while hovered (`onMouseEnter`/`onMouseLeave` forwarded) so\n * it stays readable; the caller adds the small hover-intent close delay.\n */\nexport function AnnotationHoverCard<A extends RailAnnotation>({\n item,\n anchor,\n ctx,\n showMarker = false,\n preferredSide,\n hoverFallbackSide,\n onMouseEnter,\n onMouseLeave,\n onClose,\n}: {\n item: ResolvedAnnotation<A>;\n anchor: AnnotationAnchor;\n ctx: BlockRenderContext;\n showMarker?: boolean;\n preferredSide?: AnnotationSide;\n hoverFallbackSide?: AnnotationSide | \"below\";\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n /** Called when the card should be dismissed (e.g. on scroll). */\n onClose?: () => void;\n}) {\n const cardRef = useRef<HTMLDivElement | null>(null);\n const [pos, setPos] = useState<{ top: number; left: number } | null>(null);\n\n // Measure the rendered card, then resolve a non-overlapping position: right of\n // the code if it fits, then left if that side has a clean gutter, otherwise\n // below the line.\n useLayoutEffect(() => {\n if (typeof window === \"undefined\") return;\n const el = cardRef.current;\n const rect = el?.getBoundingClientRect();\n const width = rect && rect.width > 0 ? rect.width : HOVER_CARD_WIDTH;\n const height = rect && rect.height > 0 ? rect.height : 0;\n const vw = window.innerWidth || 0;\n const vh = window.innerHeight || 0;\n setPos(\n resolveAnnotationHoverCardPosition(\n anchor,\n { width, height },\n { width: vw, height: vh },\n { preferredSide, hoverFallbackSide },\n ),\n );\n }, [\n anchor.codeRight,\n anchor.codeLeft,\n anchor.lineCenter,\n anchor.lineBottom,\n hoverFallbackSide,\n item.index,\n preferredSide,\n ]);\n\n // Close the card when the user scrolls so it doesn't float detached. Scrolls\n // inside a long hover card are local to the card and should not dismiss it.\n useEffect(() => {\n if (!onClose || typeof window === \"undefined\") return;\n const handler = (event: Event) => {\n const target = event.target;\n if (\n target instanceof Node &&\n cardRef.current &&\n cardRef.current.contains(target)\n ) {\n return;\n }\n onClose();\n };\n window.addEventListener(\"scroll\", handler, {\n capture: true,\n passive: true,\n });\n return () =>\n window.removeEventListener(\"scroll\", handler, { capture: true });\n }, [onClose]);\n\n if (typeof document === \"undefined\") return null;\n\n return createPortal(\n <div\n ref={cardRef}\n role=\"tooltip\"\n data-annotation-hover-card\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n className=\"pointer-events-auto fixed z-50 overflow-y-auto overscroll-contain\"\n style={{\n top: pos?.top ?? anchor.lineCenter,\n left: pos?.left ?? anchor.codeRight + HOVER_CARD_GAP,\n width: HOVER_CARD_WIDTH,\n maxHeight: `calc(100vh - ${VIEWPORT_MARGIN * 2}px)`,\n // Hide until measured to avoid a one-frame jump from the fallback spot.\n visibility: pos ? \"visible\" : \"hidden\",\n }}\n >\n <AnnotationCard\n item={item}\n ctx={ctx}\n active\n showMarker={showMarker}\n className=\"shadow-lg shadow-black/10 backdrop-blur-md dark:shadow-black/40\"\n />\n </div>,\n document.body,\n );\n}\n\n/**\n * Hover-intent + tap controller for the on-hover note card. Exposes\n * `activeIndex` + the captured `anchor`, plus `open`/`toggle`/`close`/\n * `scheduleClose`/`cancelClose` handlers.\n *\n * - `open(index, anchor)` shows a card immediately (cancels any pending close).\n * - `toggle(index, anchor)` opens a card if it isn't already the active one,\n * or closes it if it is — used for click/tap on annotated rows so touch users\n * can access notes without hover.\n * - `close()` hides the card immediately (used on scroll to avoid stale cards).\n * - `scheduleClose()` hides after a short delay, so moving the pointer from the\n * code line across the gap into the card itself keeps it open.\n * - `cancelClose()` (call on card mouse-enter) keeps it open while reading.\n */\nexport function useAnnotationHover(delay = 130) {\n const [active, setActive] = useState<{\n index: number;\n anchor: AnnotationAnchor;\n } | null>(null);\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const suppressHoverUntil = useRef(0);\n\n const cancelClose = () => {\n if (timer.current) {\n clearTimeout(timer.current);\n timer.current = null;\n }\n };\n const open = (index: number, anchor: AnnotationAnchor) => {\n if (Date.now() < suppressHoverUntil.current) return;\n cancelClose();\n setActive({ index, anchor });\n };\n const toggle = (index: number, anchor: AnnotationAnchor) => {\n cancelClose();\n setActive((prev) => (prev?.index === index ? null : { index, anchor }));\n };\n const close = () => {\n cancelClose();\n setActive(null);\n };\n const closeForScroll = () => {\n suppressHoverUntil.current = Date.now() + SCROLL_HOVER_SUPPRESS_MS;\n close();\n };\n const scheduleClose = () => {\n cancelClose();\n timer.current = setTimeout(() => setActive(null), delay);\n };\n\n useEffect(() => () => cancelClose(), []);\n\n return {\n activeIndex: active?.index ?? null,\n anchor: active?.anchor ?? null,\n open,\n toggle,\n close,\n closeForScroll,\n scheduleClose,\n cancelClose,\n } as const;\n}\n\n/**\n * Build an {@link AnnotationAnchor} from the code block element and the hovered\n * row element. The card anchors to the code block's RIGHT edge and the row's\n * vertical center, both in viewport coordinates (so a `fixed` portal lines up).\n */\nexport function anchorFromElements(\n codeEl: HTMLElement | null,\n rowEl: HTMLElement | null,\n): AnnotationAnchor | null {\n if (!codeEl || !rowEl) return null;\n const code = codeEl.getBoundingClientRect();\n const row = rowEl.getBoundingClientRect();\n return {\n codeRight: code.right,\n codeLeft: code.left,\n lineCenter: row.top + row.height / 2,\n lineBottom: row.bottom,\n };\n}\n\n/**\n * The responsive list of line-anchored note cards. Each card shows its marker\n * pip, the resolved line span (\"Line 8\"), an optional label, and the markdown\n * `note` (via `ctx.renderMarkdown`). Hovering a card sets the active index;\n * `activeIndex` driven from outside lets a hovered code row light its card and\n * vice-versa. Only annotations whose `range` resolved are listed.\n *\n * @deprecated Superseded by the on-hover {@link AnnotationHoverCard}; kept for\n * back-compat with any external importer. Both block read renderers now use the\n * hover popover anchored to the right of the code instead of a persistent rail.\n */\nexport function AnnotationNoteRail<A extends RailAnnotation>({\n items,\n activeIndex,\n onActiveChange,\n ctx,\n className,\n showMarker = false,\n}: {\n items: ResolvedAnnotation<A>[];\n activeIndex: number | null;\n onActiveChange: (index: number | null) => void;\n ctx: BlockRenderContext;\n className?: string;\n /** Show a leading numbered pip on each card (diff block). */\n showMarker?: boolean;\n}) {\n const sideAnnotations = useMemo(\n () => items.filter((item) => item.range),\n [items],\n );\n return (\n <div className={cn(\"flex flex-col gap-2.5\", className)}>\n {sideAnnotations.map((item) => (\n <AnnotationCard\n key={item.index}\n item={item}\n ctx={ctx}\n active={activeIndex === item.index}\n showMarker={showMarker}\n onMouseEnter={() => onActiveChange(item.index)}\n onMouseLeave={() => onActiveChange(null)}\n />\n ))}\n </div>\n );\n}\n\n/** Whether a resolved list has at least one note worth rendering a rail for. */\nexport function hasRailAnnotations(items: ResolvedAnnotation[]): boolean {\n return items.some((item) => item.range);\n}\n\nexport type AnnotationRailChildren = ReactNode;\n"]}
|
|
1
|
+
{"version":3,"file":"annotation-rail.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/annotation-rail.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GAIT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAGpC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,kFAAkF;AAElF;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAW,EACX,SAAiB;IAEjB,MAAM,KAAK,GAAG,gCAAgC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,IAAI,CAAC,KAA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QAAQ,EAAE,IAAI,CAAC,IAAI;QACnB,UAAU,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC;QACpC,UAAU,EAAE,GAAG,CAAC,MAAM;KACvB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAA2B,EAC3D,KAAK,EACL,WAAW,EACX,cAAc,EACd,GAAG,EACH,SAAS,EACT,UAAU,GAAG,KAAK,GASnB;IACC,MAAM,eAAe,GAAG,OAAO,CAC7B,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EACxC,CAAC,KAAK,CAAC,CACR,CAAC;IACF,OAAO,CACL,cAAK,SAAS,EAAE,EAAE,CAAC,uBAAuB,EAAE,SAAS,CAAC,YACnD,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAC7B,KAAC,cAAc,IAEb,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC,KAAK,EAClC,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,EAC9C,YAAY,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,IANnC,IAAI,CAAC,KAAK,CAOf,CACH,CAAC,GACE,CACP,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,kBAAkB,CAAC,KAA2B;IAC5D,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import {\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type RefObject,\n type ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../../utils.js\";\nimport type { BlockRenderContext } from \"../types.js\";\n\n/**\n * Shared line-anchored annotation UI for the `annotated-code` and `diff` blocks.\n *\n * Both blocks render a numbered code surface plus a side \"rail\" of notes, where\n * each note targets a 1-based `lines` ref (`\"3\"` or `\"3-5\"`) and hovering a code\n * line ↔ its note cross-highlights. This module owns the pure pieces that were\n * identical between them so neither block forks the behavior:\n *\n * - `parseLineRange` — the forgiving 1-based `lines` range parser.\n * - `resolveAnnotations` / `buildLineMarkerMap` — turn a raw annotation list\n * into stable, marker-numbered, range-resolved records and a line→markers map.\n * - `rangeLabel` — the human \"Line 8\" / \"Lines 3–6\" label.\n * - `AnnotationGutterMarker` — the numbered amber pip placed on an annotated row\n * (used by the diff grid; the annotated-code surface uses its own rail bar).\n * - `AnnotationNoteRail` — the responsive list of note cards with two-way hover.\n * `showMarker` opts the diff block into a leading numbered pip on each card so\n * a note can be matched to its `①`/`②` row marker; annotated-code omits it to\n * keep its original card chrome.\n *\n * `AnnotatedCodeBlock` annotates a single code surface; `DiffBlock` annotates a\n * before/after grid (each annotation also carries a `side`). The shared types\n * here are intentionally minimal — callers pass their own `side` handling and\n * decide which rows a marker lands on; this module only owns the parsing, the\n * resolved-record shape, and the rendered marker + rail chrome.\n */\n\n/* ── Line-ref parsing ──────────────────────────────────────────────────────── */\n\n/**\n * Parse a 1-based `lines` ref (`\"3\"` or `\"3-5\"`) into an inclusive `[start,end]`\n * pair, clamped to `[1, lineCount]`. Returns `null` for malformed or fully\n * out-of-range refs so callers can ignore them gracefully. A reversed range\n * (`\"5-3\"`) is normalized; a partially out-of-range range is clamped.\n */\nexport function parseLineRange(\n ref: string,\n lineCount: number,\n): { start: number; end: number } | null {\n const match = /^\\s*(\\d+)\\s*(?:-\\s*(\\d+)\\s*)?$/.exec(ref);\n if (!match) return null;\n let start = Number.parseInt(match[1], 10);\n let end = match[2] != null ? Number.parseInt(match[2], 10) : start;\n if (!Number.isFinite(start) || !Number.isFinite(end)) return null;\n if (start > end) [start, end] = [end, start];\n // Fully outside the file → ignore.\n if (end < 1 || start > lineCount) return null;\n return { start: Math.max(1, start), end: Math.min(lineCount, end) };\n}\n\n/** The minimal annotation shape the rail needs (a superset works too). */\nexport interface RailAnnotation {\n lines: string;\n label?: string;\n note: string;\n}\n\nexport interface ResolvedAnnotation<A extends RailAnnotation = RailAnnotation> {\n /** Index in the original `annotations` array (stable hover key). */\n index: number;\n /** 1-based marker number (authoring order). */\n marker: number;\n annotation: A;\n range: { start: number; end: number } | null;\n}\n\n/**\n * Resolve a raw annotation list into stable, marker-numbered records, parsing\n * each `lines` ref against `lineCount`. `lineCountFor` lets the diff block pick a\n * per-annotation line count (before-side vs after-side); annotated-code passes a\n * single constant. Markers are authoring-order, 1-based, and assigned to ALL\n * annotations (even unresolved ones) so numbering is stable regardless of which\n * refs happen to match.\n */\nexport function resolveAnnotations<A extends RailAnnotation>(\n annotations: A[] | undefined,\n lineCountFor: (annotation: A) => number,\n): ResolvedAnnotation<A>[] {\n return (annotations ?? []).map((annotation, index) => ({\n index,\n marker: index + 1,\n annotation,\n range: parseLineRange(annotation.lines, lineCountFor(annotation)),\n }));\n}\n\n/** Map a 1-based line number → the resolved annotations covering it. */\nexport function buildLineMarkerMap<A extends RailAnnotation>(\n resolved: ResolvedAnnotation<A>[],\n): Map<number, ResolvedAnnotation<A>[]> {\n const map = new Map<number, ResolvedAnnotation<A>[]>();\n for (const item of resolved) {\n if (!item.range) continue;\n for (let n = item.range.start; n <= item.range.end; n += 1) {\n const list = map.get(n) ?? [];\n list.push(item);\n map.set(n, list);\n }\n }\n return map;\n}\n\n/** Human label for a resolved annotation's line span (\"Line 8\" / \"Lines 3–6\"). */\nexport function rangeLabel(item: ResolvedAnnotation): string {\n if (!item.range) return `Lines ${item.annotation.lines}`;\n return item.range.start === item.range.end\n ? `Line ${item.range.start}`\n : `Lines ${item.range.start}–${item.range.end}`;\n}\n\n/* ── Marker ────────────────────────────────────────────────────────────────── */\n\n/**\n * The numbered amber pip rendered on an annotated code row's gutter. `active`\n * brightens it when its note (or a co-located row) is hovered.\n */\nexport function AnnotationGutterMarker({\n marker,\n active,\n className,\n}: {\n marker: number;\n active: boolean;\n className?: string;\n}) {\n return (\n <span\n aria-hidden\n className={cn(\n \"inline-flex size-[15px] shrink-0 items-center justify-center rounded-full text-[9px] font-semibold leading-none tabular-nums transition-colors\",\n active\n ? \"bg-yellow-400 text-yellow-950 dark:bg-yellow-300 dark:text-yellow-950\"\n : \"bg-yellow-300/25 text-yellow-800 dark:bg-yellow-300/16 dark:text-yellow-200\",\n className,\n )}\n >\n {marker}\n </span>\n );\n}\n\n/* ── Note card ─────────────────────────────────────────────────────────────── */\n\n/**\n * One line-anchored note card: marker pip (when `showMarker`), the resolved line\n * span (\"Line 8\"), an optional label, and the markdown `note` (via\n * `ctx.renderMarkdown`). This is the single source of card markup, rendered both\n * by the visually-hidden a11y/test stack and by the on-hover portal popover.\n */\nexport function AnnotationCard<A extends RailAnnotation>({\n item,\n ctx,\n active = false,\n showMarker = false,\n className,\n onMouseEnter,\n onMouseLeave,\n}: {\n item: ResolvedAnnotation<A>;\n ctx: BlockRenderContext;\n active?: boolean;\n showMarker?: boolean;\n className?: string;\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n}) {\n return (\n <div\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n className={cn(\n \"rounded-lg border px-3.5 py-2.5 shadow-lg shadow-black/10 backdrop-blur-xl transition-colors dark:shadow-black/40\",\n active\n ? \"border-yellow-300/55 bg-yellow-50/80 dark:border-yellow-200/25 dark:bg-yellow-300/[0.10]\"\n : \"border-plan-line bg-plan-block hover:border-yellow-300/45\",\n className,\n )}\n >\n <div\n className={cn(\n \"flex min-w-0 flex-wrap gap-x-2 gap-y-1\",\n showMarker ? \"items-center\" : \"items-baseline\",\n )}\n >\n {showMarker && (\n <AnnotationGutterMarker marker={item.marker} active={active} />\n )}\n <span className=\"shrink-0 text-[11px] font-semibold uppercase tracking-wide text-plan-muted\">\n {rangeLabel(item)}\n </span>\n {item.annotation.label && (\n <span className=\"min-w-0 max-w-full flex-1 break-words text-[13px] font-semibold leading-snug text-plan-text [overflow-wrap:anywhere]\">\n {item.annotation.label}\n </span>\n )}\n </div>\n <div className=\"plan-annotation-note mt-1 break-words text-[13px] leading-relaxed text-plan-text/85 [overflow-wrap:anywhere]\">\n {ctx.renderMarkdown ? (\n ctx.renderMarkdown(item.annotation.note)\n ) : (\n <p>{item.annotation.note}</p>\n )}\n </div>\n </div>\n );\n}\n\n/**\n * Visually-hidden stack of every resolved note. It is NOT a visible column — it\n * sits in the flow but clipped to a 1px box (the `sr-only` pattern) so the note\n * text and the per-card marker pips stay in the accessibility tree and in the\n * DOM (assistive tech can reach them, and tests that read `textContent`/count\n * pips still see them) WITHOUT painting a persistent rail beside the code. The\n * visible card appears only on hover via {@link AnnotationHoverCard}.\n */\nexport function AnnotationHiddenStack<A extends RailAnnotation>({\n items,\n ctx,\n showMarker = false,\n}: {\n items: ResolvedAnnotation<A>[];\n ctx: BlockRenderContext;\n showMarker?: boolean;\n}) {\n const resolved = useMemo(() => items.filter((item) => item.range), [items]);\n if (resolved.length === 0) return null;\n return (\n <div\n className=\"absolute size-px overflow-hidden whitespace-nowrap border-0 p-0 [clip:rect(0,0,0,0)] [clip-path:inset(50%)]\"\n data-annotation-hidden-stack\n >\n {resolved.map((item) => (\n <AnnotationCard\n key={item.index}\n item={item}\n ctx={ctx}\n showMarker={showMarker}\n />\n ))}\n </div>\n );\n}\n\nexport function AnnotationInlineOverlayStack<A extends RailAnnotation>({\n items,\n ctx,\n showMarker = false,\n containerRef,\n mode = \"capture\",\n side = \"right\",\n preferredSide = \"right\",\n}: {\n items: ResolvedAnnotation<A>[];\n ctx: BlockRenderContext;\n showMarker?: boolean;\n containerRef?: RefObject<HTMLElement | null>;\n mode?: \"capture\" | \"margin\";\n side?: AnnotationMarginSide;\n preferredSide?: AnnotationSide;\n}) {\n const resolved = items.filter((item) => item.range);\n const anchorRef = useRef<HTMLDivElement | null>(null);\n const portalRef = useRef<HTMLDivElement | null>(null);\n const [position, setPosition] = useState<\n | { kind: \"capture\"; top: number; left: number; visible: boolean }\n | {\n kind: \"margin\";\n top: number;\n left: number;\n visible: boolean;\n side: AnnotationSide;\n }\n | null\n >(null);\n const positionKey = resolved\n .map(\n (item) =>\n `${item.index}:${item.marker}:${item.annotation.lines}:${item.annotation.label ?? \"\"}:${item.annotation.note}`,\n )\n .join(\"|\");\n\n useLayoutEffect(() => {\n if (typeof window === \"undefined\") return;\n const anchor = anchorRef.current;\n if (!anchor) return;\n\n let frame: number | null = null;\n const updatePosition = () => {\n frame = null;\n const anchorRect = anchor.getBoundingClientRect();\n const portalRect = portalRef.current?.getBoundingClientRect();\n const viewportWidth = Math.max(\n window.innerWidth || 0,\n INLINE_OVERLAY_WIDTH + VIEWPORT_MARGIN * 2,\n );\n const viewportHeight = Math.max(\n window.innerHeight || 0,\n VIEWPORT_MARGIN * 2,\n );\n const width =\n portalRect && portalRect.width > 0\n ? portalRect.width\n : Math.min(INLINE_OVERLAY_WIDTH, viewportWidth * 0.45);\n const height =\n portalRect && portalRect.height > 0 ? portalRect.height : 0;\n if (mode === \"margin\") {\n const containerRect =\n containerRef?.current?.getBoundingClientRect() ?? anchorRect;\n const next = resolveAnnotationMarginOverlayPosition(\n {\n left: containerRect.left,\n right: containerRect.right,\n top: anchorRect.top,\n height: anchorRect.height,\n },\n { width, height },\n { width: viewportWidth, height: viewportHeight },\n { side, preferredSide },\n );\n setPosition({ kind: \"margin\", ...next });\n return;\n }\n const scroll = {\n x: window.scrollX || window.pageXOffset || 0,\n y: window.scrollY || window.pageYOffset || 0,\n };\n setPosition({\n kind: \"capture\",\n visible: Boolean(portalRect && portalRect.height > 0),\n ...resolveAnnotationCaptureOverlayPosition(\n {\n right: anchorRect.right,\n top: anchorRect.top,\n height: anchorRect.height,\n },\n { width, height },\n { width: viewportWidth, height: viewportHeight },\n scroll,\n ),\n });\n };\n const scheduleUpdatePosition = () => {\n if (frame != null) return;\n if (typeof window.requestAnimationFrame === \"function\") {\n frame = window.requestAnimationFrame(updatePosition);\n return;\n }\n updatePosition();\n };\n\n updatePosition();\n scheduleUpdatePosition();\n window.addEventListener(\"resize\", updatePosition);\n window.addEventListener(\"scroll\", scheduleUpdatePosition, {\n capture: true,\n passive: true,\n });\n return () => {\n if (frame != null && typeof window.cancelAnimationFrame === \"function\") {\n window.cancelAnimationFrame(frame);\n }\n window.removeEventListener(\"resize\", updatePosition);\n window.removeEventListener(\"scroll\", scheduleUpdatePosition, {\n capture: true,\n });\n };\n }, [containerRef, mode, positionKey, preferredSide, side]);\n\n if (resolved.length === 0) return null;\n\n const portalStyle: CSSProperties =\n position?.kind === \"margin\"\n ? {\n top: position.top,\n left: position.left,\n visibility:\n position.visible && position\n ? (\"visible\" as const)\n : (\"hidden\" as const),\n }\n : {\n top: position?.top ?? VIEWPORT_MARGIN,\n left:\n position && position.kind === \"capture\"\n ? position.left\n : VIEWPORT_MARGIN,\n visibility:\n position?.kind === \"capture\" && position.visible\n ? (\"visible\" as const)\n : (\"hidden\" as const),\n };\n\n const portal =\n typeof document === \"undefined\"\n ? null\n : createPortal(\n <div\n aria-hidden\n ref={portalRef}\n data-annotation-inline-overlay\n data-annotation-inline-overlay-mode={mode}\n data-annotation-inline-overlay-side={\n position?.kind === \"margin\" ? position.side : \"right\"\n }\n className={cn(\n \"pointer-events-none z-50 flex w-[min(20rem,45vw)] flex-col gap-2\",\n mode === \"capture\" ? \"absolute\" : \"fixed\",\n )}\n style={portalStyle}\n >\n {resolved.map((item) => (\n <AnnotationCard\n key={item.index}\n item={item}\n ctx={ctx}\n active\n showMarker={showMarker}\n className=\"border-yellow-300/55 bg-yellow-50/80 shadow-lg shadow-black/10 backdrop-blur-xl dark:border-yellow-200/25 dark:bg-yellow-300/[0.10] dark:shadow-black/50\"\n />\n ))}\n </div>,\n document.body,\n );\n\n return (\n <>\n <div\n aria-hidden\n ref={anchorRef}\n data-annotation-inline-overlay-anchor\n className=\"pointer-events-none absolute right-3 top-0 z-20 h-0 w-0 overflow-visible\"\n />\n {portal}\n </>\n );\n}\n\n/* ── Hover popover (portal, anchored beside the code) ──────────────────────── */\n\n/** The geometry the hover card anchors to (in viewport coordinates). */\nexport interface AnnotationAnchor {\n /** Right edge of the code block (where the card should start). */\n codeRight: number;\n /** Left edge of the code block (for the below-fallback alignment). */\n codeLeft: number;\n /** Vertical center of the hovered line. */\n lineCenter: number;\n /** Bottom of the hovered line (for the below-fallback placement). */\n lineBottom: number;\n}\n\nexport type AnnotationSide = \"left\" | \"right\";\nexport type AnnotationMarginSide = AnnotationSide | \"auto\";\n\nconst HOVER_CARD_WIDTH = 280;\nconst INLINE_OVERLAY_WIDTH = 320;\nconst HOVER_CARD_GAP = 12;\nconst HOVER_CARD_OVERHANG = 40;\nconst VIEWPORT_MARGIN = 8;\nconst SCROLL_HOVER_SUPPRESS_MS = 260;\n\nfunction oppositeSide(side: AnnotationSide): AnnotationSide {\n return side === \"left\" ? \"right\" : \"left\";\n}\n\nfunction clampWithinViewport(\n value: number,\n size: number,\n viewportSize: number,\n): number {\n return Math.max(\n VIEWPORT_MARGIN,\n Math.min(value, viewportSize - size - VIEWPORT_MARGIN),\n );\n}\n\nfunction centeredTop(\n anchor: { top: number; height: number },\n cardHeight: number,\n viewportHeight: number,\n): number {\n const maxTop = Math.max(\n VIEWPORT_MARGIN,\n viewportHeight - cardHeight - VIEWPORT_MARGIN,\n );\n const raw = anchor.top + anchor.height / 2 - cardHeight / 2;\n return Math.max(VIEWPORT_MARGIN, Math.min(raw, maxTop));\n}\n\nfunction inlineOverlayWidthForViewport(viewportWidth: number): number {\n return Math.min(INLINE_OVERLAY_WIDTH, Math.max(0, viewportWidth * 0.45));\n}\n\nfunction hoverCardLeftForSide(\n side: AnnotationSide,\n anchor: AnnotationAnchor,\n cardWidth: number,\n): number {\n return side === \"right\"\n ? anchor.codeRight + HOVER_CARD_GAP\n : anchor.codeLeft - HOVER_CARD_GAP - cardWidth;\n}\n\nfunction hoverCardOverlapLeftForSide(\n side: AnnotationSide,\n anchor: AnnotationAnchor,\n cardWidth: number,\n): number {\n return side === \"right\"\n ? anchor.codeRight - cardWidth + HOVER_CARD_OVERHANG\n : anchor.codeLeft - HOVER_CARD_OVERHANG;\n}\n\nfunction hoverCardFitsSide(\n side: AnnotationSide,\n anchor: AnnotationAnchor,\n cardWidth: number,\n viewportWidth: number,\n): boolean {\n const left = hoverCardLeftForSide(side, anchor, cardWidth);\n return (\n left >= VIEWPORT_MARGIN &&\n left + cardWidth + VIEWPORT_MARGIN <= viewportWidth\n );\n}\n\nexport function resolveAnnotationInlineOverlayPosition(\n anchor: { right: number; top: number; height: number },\n card: { width: number; height: number },\n viewport: { width: number; height: number },\n): { top: number; right: number } {\n const maxRight = Math.max(\n VIEWPORT_MARGIN,\n viewport.width - card.width - VIEWPORT_MARGIN,\n );\n\n return {\n top: centeredTop(anchor, card.height, viewport.height),\n right: Math.max(\n VIEWPORT_MARGIN,\n Math.min(viewport.width - anchor.right, maxRight),\n ),\n };\n}\n\nexport function resolveAnnotationCaptureOverlayPosition(\n anchor: { right: number; top: number; height: number },\n card: { width: number; height: number },\n viewport: { width: number; height: number },\n scroll: { x: number; y: number } = { x: 0, y: 0 },\n): { top: number; left: number } {\n const { right } = resolveAnnotationInlineOverlayPosition(\n anchor,\n card,\n viewport,\n );\n const left = scroll.x + viewport.width - right - card.width;\n const rawTop = anchor.top + anchor.height / 2 - card.height / 2;\n return {\n top: Math.max(scroll.y + VIEWPORT_MARGIN, scroll.y + rawTop),\n left,\n };\n}\n\nexport function resolveAnnotationMarginOverlayPosition(\n anchor: { left: number; right: number; top: number; height: number },\n card: { width: number; height: number },\n viewport: { width: number; height: number },\n options: {\n side?: AnnotationMarginSide;\n preferredSide?: AnnotationSide;\n } = {},\n): { top: number; left: number; visible: boolean; side: AnnotationSide } {\n const preferredSide = options.preferredSide ?? \"left\";\n const requestedSide = options.side ?? preferredSide;\n const sides: AnnotationSide[] =\n requestedSide === \"auto\"\n ? [preferredSide, oppositeSide(preferredSide)]\n : [requestedSide];\n const top = centeredTop(anchor, card.height, viewport.height);\n\n for (const candidate of sides) {\n const left =\n candidate === \"left\"\n ? anchor.left - HOVER_CARD_GAP - card.width\n : anchor.right + HOVER_CARD_GAP;\n const fits =\n left >= VIEWPORT_MARGIN &&\n left + card.width + VIEWPORT_MARGIN <= viewport.width;\n if (fits) return { top, left, visible: true, side: candidate };\n }\n\n const fallbackSide = requestedSide === \"auto\" ? preferredSide : requestedSide;\n const fallbackLeft =\n fallbackSide === \"left\"\n ? anchor.left - HOVER_CARD_GAP - card.width\n : anchor.right + HOVER_CARD_GAP;\n return {\n top,\n left: clampWithinViewport(fallbackLeft, card.width, viewport.width),\n visible: false,\n side: fallbackSide,\n };\n}\n\nexport function resolveAnnotationHoverCardPosition(\n anchor: AnnotationAnchor,\n card: { width: number; height: number },\n viewport: { width: number; height: number },\n options: {\n preferredSide?: AnnotationSide;\n hoverFallbackSide?: AnnotationSide | \"below\";\n allowOppositeSideFallback?: boolean;\n } = {},\n): { top: number; left: number } {\n const preferredSide = options.preferredSide ?? \"right\";\n const hoverFallbackSide = options.hoverFallbackSide ?? \"right\";\n const allowOppositeSideFallback = options.allowOppositeSideFallback ?? true;\n const opposite = oppositeSide(preferredSide);\n\n let left: number;\n let top: number;\n if (hoverCardFitsSide(preferredSide, anchor, card.width, viewport.width)) {\n left = hoverCardLeftForSide(preferredSide, anchor, card.width);\n top = anchor.lineCenter - card.height / 2;\n } else if (\n allowOppositeSideFallback &&\n hoverCardFitsSide(opposite, anchor, card.width, viewport.width)\n ) {\n left = hoverCardLeftForSide(opposite, anchor, card.width);\n top = anchor.lineCenter - card.height / 2;\n } else if (hoverFallbackSide === \"left\" || hoverFallbackSide === \"right\") {\n left = hoverCardOverlapLeftForSide(hoverFallbackSide, anchor, card.width);\n top = anchor.lineCenter - card.height / 2;\n } else {\n // No clean side gutter → drop below the line, aligned to the code's left.\n left = anchor.codeLeft;\n top = anchor.lineBottom + HOVER_CARD_GAP;\n }\n\n // Clamp within the viewport so the card is never cut off.\n left = clampWithinViewport(left, card.width, viewport.width);\n top = Math.max(\n VIEWPORT_MARGIN,\n Math.min(top, viewport.height - card.height - VIEWPORT_MARGIN),\n );\n\n return { top, left };\n}\n\nexport function useAnnotationMarginNotesAvailable({\n containerRef,\n enabled,\n side = \"auto\",\n preferredSide = \"left\",\n}: {\n containerRef: RefObject<HTMLElement | null>;\n enabled: boolean;\n side?: AnnotationMarginSide;\n preferredSide?: AnnotationSide;\n}) {\n const [available, setAvailable] = useState(false);\n\n useLayoutEffect(() => {\n if (!enabled || typeof window === \"undefined\") {\n setAvailable(false);\n return;\n }\n\n const update = () => {\n const element = containerRef.current;\n if (!element) {\n setAvailable(false);\n return;\n }\n const rect = element.getBoundingClientRect();\n const viewportWidth = Math.max(window.innerWidth || 0, 0);\n const cardWidth = inlineOverlayWidthForViewport(viewportWidth);\n const leftFits =\n rect.left - HOVER_CARD_GAP - cardWidth >= VIEWPORT_MARGIN;\n const rightFits =\n rect.right + HOVER_CARD_GAP + cardWidth + VIEWPORT_MARGIN <=\n viewportWidth;\n const next =\n side === \"left\"\n ? leftFits\n : side === \"right\"\n ? rightFits\n : preferredSide === \"left\"\n ? leftFits || rightFits\n : rightFits || leftFits;\n setAvailable(next);\n };\n\n update();\n const frame =\n typeof window.requestAnimationFrame === \"function\"\n ? window.requestAnimationFrame(update)\n : null;\n const observer =\n typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(update) : null;\n if (containerRef.current && observer)\n observer.observe(containerRef.current);\n window.addEventListener(\"resize\", update);\n return () => {\n if (frame != null && typeof window.cancelAnimationFrame === \"function\") {\n window.cancelAnimationFrame(frame);\n }\n observer?.disconnect();\n window.removeEventListener(\"resize\", update);\n };\n }, [containerRef, enabled, preferredSide, side]);\n\n return available;\n}\n\n/**\n * The single on-hover note card, portaled to `document.body` and positioned\n * `fixed` so it escapes the code block's `overflow` and never reflows the code.\n *\n * Placement: by default it sits to the RIGHT of the code block's right edge,\n * vertically centered on the hovered line — so it never overlaps the code text.\n * If there isn't room to the right, it uses the LEFT of the code block when the\n * card can fit there without covering code. Only when neither side fits does it\n * overlap the code from the RIGHT edge with a small overhang, so the hover still\n * reads as an attached overlay instead of a left-aligned card. The card keeps\n * itself open while hovered (`onMouseEnter`/`onMouseLeave` forwarded) so it stays\n * readable; the caller adds the small hover-intent close delay.\n */\nexport function AnnotationHoverCard<A extends RailAnnotation>({\n item,\n anchor,\n ctx,\n showMarker = false,\n preferredSide,\n hoverFallbackSide,\n onMouseEnter,\n onMouseLeave,\n onClose,\n}: {\n item: ResolvedAnnotation<A>;\n anchor: AnnotationAnchor;\n ctx: BlockRenderContext;\n showMarker?: boolean;\n preferredSide?: AnnotationSide;\n hoverFallbackSide?: AnnotationSide | \"below\";\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n /** Called when the card should be dismissed (e.g. on scroll). */\n onClose?: () => void;\n}) {\n const cardRef = useRef<HTMLDivElement | null>(null);\n const [pos, setPos] = useState<{ top: number; left: number } | null>(null);\n\n // Measure the rendered card, then resolve a non-overlapping position: right of\n // the code if it fits, then left if that side has a clean gutter, otherwise\n // below the line.\n useLayoutEffect(() => {\n if (typeof window === \"undefined\") return;\n const el = cardRef.current;\n const rect = el?.getBoundingClientRect();\n const width = rect && rect.width > 0 ? rect.width : HOVER_CARD_WIDTH;\n const height = rect && rect.height > 0 ? rect.height : 0;\n const vw = window.innerWidth || 0;\n const vh = window.innerHeight || 0;\n setPos(\n resolveAnnotationHoverCardPosition(\n anchor,\n { width, height },\n { width: vw, height: vh },\n { preferredSide, hoverFallbackSide },\n ),\n );\n }, [\n anchor.codeRight,\n anchor.codeLeft,\n anchor.lineCenter,\n anchor.lineBottom,\n hoverFallbackSide,\n item.index,\n preferredSide,\n ]);\n\n // Close the card when the user scrolls so it doesn't float detached. Scrolls\n // inside a long hover card are local to the card and should not dismiss it.\n useEffect(() => {\n if (!onClose || typeof window === \"undefined\") return;\n const handler = (event: Event) => {\n const target = event.target;\n if (\n target instanceof Node &&\n cardRef.current &&\n cardRef.current.contains(target)\n ) {\n return;\n }\n onClose();\n };\n window.addEventListener(\"scroll\", handler, {\n capture: true,\n passive: true,\n });\n return () =>\n window.removeEventListener(\"scroll\", handler, { capture: true });\n }, [onClose]);\n\n if (typeof document === \"undefined\") return null;\n\n return createPortal(\n <div\n ref={cardRef}\n role=\"tooltip\"\n data-annotation-hover-card\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n className=\"pointer-events-auto fixed z-50 overflow-y-auto overscroll-contain\"\n style={{\n top: pos?.top ?? anchor.lineCenter,\n left: pos?.left ?? anchor.codeRight + HOVER_CARD_GAP,\n width: HOVER_CARD_WIDTH,\n maxHeight: `calc(100vh - ${VIEWPORT_MARGIN * 2}px)`,\n // Hide until measured to avoid a one-frame jump from the fallback spot.\n visibility: pos ? \"visible\" : \"hidden\",\n }}\n >\n <AnnotationCard\n item={item}\n ctx={ctx}\n active\n showMarker={showMarker}\n className=\"shadow-lg shadow-black/10 backdrop-blur-md dark:shadow-black/40\"\n />\n </div>,\n document.body,\n );\n}\n\n/**\n * Hover-intent + tap controller for the on-hover note card. Exposes\n * `activeIndex` + the captured `anchor`, plus `open`/`toggle`/`close`/\n * `scheduleClose`/`cancelClose` handlers.\n *\n * - `open(index, anchor)` shows a card immediately (cancels any pending close).\n * - `toggle(index, anchor)` opens a card if it isn't already the active one,\n * or closes it if it is — used for click/tap on annotated rows so touch users\n * can access notes without hover.\n * - `close()` hides the card immediately (used on scroll to avoid stale cards).\n * - `scheduleClose()` hides after a short delay, so moving the pointer from the\n * code line across the gap into the card itself keeps it open.\n * - `cancelClose()` (call on card mouse-enter) keeps it open while reading.\n */\nexport function useAnnotationHover(delay = 130) {\n const [active, setActive] = useState<{\n index: number;\n anchor: AnnotationAnchor;\n } | null>(null);\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const suppressHoverUntil = useRef(0);\n\n const cancelClose = () => {\n if (timer.current) {\n clearTimeout(timer.current);\n timer.current = null;\n }\n };\n const open = (index: number, anchor: AnnotationAnchor) => {\n if (Date.now() < suppressHoverUntil.current) return;\n cancelClose();\n setActive({ index, anchor });\n };\n const toggle = (index: number, anchor: AnnotationAnchor) => {\n cancelClose();\n setActive((prev) => (prev?.index === index ? null : { index, anchor }));\n };\n const close = () => {\n cancelClose();\n setActive(null);\n };\n const closeForScroll = () => {\n suppressHoverUntil.current = Date.now() + SCROLL_HOVER_SUPPRESS_MS;\n close();\n };\n const scheduleClose = () => {\n cancelClose();\n timer.current = setTimeout(() => setActive(null), delay);\n };\n\n useEffect(() => () => cancelClose(), []);\n\n return {\n activeIndex: active?.index ?? null,\n anchor: active?.anchor ?? null,\n open,\n toggle,\n close,\n closeForScroll,\n scheduleClose,\n cancelClose,\n } as const;\n}\n\n/**\n * Build an {@link AnnotationAnchor} from the code block element and the hovered\n * row element. The card anchors to the code block's RIGHT edge and the row's\n * vertical center, both in viewport coordinates (so a `fixed` portal lines up).\n */\nexport function anchorFromElements(\n codeEl: HTMLElement | null,\n rowEl: HTMLElement | null,\n): AnnotationAnchor | null {\n if (!codeEl || !rowEl) return null;\n const code = codeEl.getBoundingClientRect();\n const row = rowEl.getBoundingClientRect();\n return {\n codeRight: code.right,\n codeLeft: code.left,\n lineCenter: row.top + row.height / 2,\n lineBottom: row.bottom,\n };\n}\n\n/**\n * The responsive list of line-anchored note cards. Each card shows its marker\n * pip, the resolved line span (\"Line 8\"), an optional label, and the markdown\n * `note` (via `ctx.renderMarkdown`). Hovering a card sets the active index;\n * `activeIndex` driven from outside lets a hovered code row light its card and\n * vice-versa. Only annotations whose `range` resolved are listed.\n *\n * @deprecated Superseded by the on-hover {@link AnnotationHoverCard}; kept for\n * back-compat with any external importer. Both block read renderers now use the\n * hover popover anchored to the right of the code instead of a persistent rail.\n */\nexport function AnnotationNoteRail<A extends RailAnnotation>({\n items,\n activeIndex,\n onActiveChange,\n ctx,\n className,\n showMarker = false,\n}: {\n items: ResolvedAnnotation<A>[];\n activeIndex: number | null;\n onActiveChange: (index: number | null) => void;\n ctx: BlockRenderContext;\n className?: string;\n /** Show a leading numbered pip on each card (diff block). */\n showMarker?: boolean;\n}) {\n const sideAnnotations = useMemo(\n () => items.filter((item) => item.range),\n [items],\n );\n return (\n <div className={cn(\"flex flex-col gap-2.5\", className)}>\n {sideAnnotations.map((item) => (\n <AnnotationCard\n key={item.index}\n item={item}\n ctx={ctx}\n active={activeIndex === item.index}\n showMarker={showMarker}\n onMouseEnter={() => onActiveChange(item.index)}\n onMouseLeave={() => onActiveChange(null)}\n />\n ))}\n </div>\n );\n}\n\n/** Whether a resolved list has at least one note worth rendering a rail for. */\nexport function hasRailAnnotations(items: ResolvedAnnotation[]): boolean {\n return items.some((item) => item.range);\n}\n\nexport type AnnotationRailChildren = ReactNode;\n"]}
|
|
@@ -121,8 +121,8 @@ export interface BlockRenderContext {
|
|
|
121
121
|
hoverSide?: "left" | "right";
|
|
122
122
|
/**
|
|
123
123
|
* Final hover fallback when neither side has a clean gutter. `"below"` keeps
|
|
124
|
-
* the legacy line-below behavior; `"left"`/`"right"`
|
|
125
|
-
*
|
|
124
|
+
* the legacy line-below behavior; `"left"`/`"right"` overlap the card from
|
|
125
|
+
* that code edge with a small overhang.
|
|
126
126
|
*/
|
|
127
127
|
hoverFallbackSide?: "left" | "right" | "below";
|
|
128
128
|
/** Show all annotation cards by default when the requested margin fits. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/blocks/types.ts"],"names":[],"mappings":"AAqYA,qEAAqE;AACrE,MAAM,UAAU,WAAW,CAAQ,IAAsB;IACvD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { FC } from \"react\";\nimport type { ZodType } from \"zod\";\n\n/**\n * Block-registry contract. A `BlockSpec` describes one document block end to end:\n * its data shape (`schema`), how it round-trips to MDX source (`mdx`), how it\n * renders read-only (`Read`) and how it is edited (`Edit`, or an auto-generated\n * schema-driven editor when omitted), where it can be placed (`placement`), and\n * metadata for menus / agent schema export.\n *\n * The registry runs ALONGSIDE existing per-block code (the plan `PlanBlockView`\n * switch + `serializeBlock`/`parseBlock`). Renderers check the registry first;\n * unregistered block types fall through to the legacy code path unchanged. The\n * MDX `tag` and attribute shape for a converted block MUST match the historical\n * encoding (e.g. `<Callout tone>…body…</Callout>`) so stored `.mdx` files still\n * parse byte-compatibly.\n */\n\n/** Where a block can be placed in a document. */\nexport type BlockPlacement = \"block\" | \"inline\";\n\n/**\n * A serialized MDX/NFM attribute value before the shared `prop()` encoder runs.\n * `prop()` decides string-vs-JSON encoding; this is just the value domain.\n */\nexport type MdxAttrValue =\n | string\n | number\n | boolean\n | unknown[]\n | Record<string, unknown>;\n\n/**\n * Type-narrowed reader over the resolved MDX attributes of a parsed block node.\n * The values are already estree/JSON-resolved by the shared attribute reader\n * (the same engine `plan-mdx.ts` uses), so a spec's `fromAttrs` never touches\n * the AST directly.\n */\nexport interface BlockAttrReader {\n string(name: string): string | undefined;\n number(name: string): number | undefined;\n bool(name: string): boolean | undefined;\n array<T = unknown>(name: string): T[] | undefined;\n object<T = unknown>(name: string): T | undefined;\n raw(name: string): unknown;\n}\n\n/**\n * Maps a block's validated data to/from its MDX component representation.\n * `tag` is the JSX component name in source (e.g. \"Callout\"). It MUST match the\n * historical name in `plan-mdx.ts` `BLOCK_COMPONENTS` / stored `.mdx` files or\n * existing plans break.\n */\nexport interface BlockMdxConfig<TData> {\n /** JSX component name in MDX source. Stable contract — never rename. */\n tag: string;\n /**\n * Encode `data` → a flat attribute bag. The registry serializer runs each\n * value through the shared `prop()` encoder (string-vs-JSON heuristic) and\n * preserves insertion order, so write the keys in the exact historical order.\n * Return `undefined` for a key (or omit it) to drop the attribute. When\n * `childrenField` is set, that field is excluded from the attribute bag.\n */\n toAttrs: (data: TData) => Record<string, MdxAttrValue | undefined>;\n /**\n * Decode resolved attributes (+ optional children markdown) → data. Must\n * tolerate missing/partial attributes for backward-compat (mirror today's\n * `?? []` / `?? \"\"` defaults).\n */\n fromAttrs: (attrs: BlockAttrReader, children: string) => TData;\n /**\n * When set, this data field is a markdown string serialized as MDX *children*\n * between the open/close tags (prose-bearing blocks: rich-text, callout)\n * rather than as a prop — so the body survives as real, inline-editable MDX\n * prose in source.\n */\n childrenField?: keyof TData & string;\n /**\n * Opt-in custom children serializer for blocks whose internals are nested MDX\n * components rather than a single markdown string (e.g. wireframe → Screen/kit\n * primitives). When present it overrides `childrenField`. `serializeChildren`\n * returns the raw inner MDX; `parseChildren` receives the child MDX AST nodes.\n */\n serializeChildren?: (data: TData) => string;\n parseChildren?: (childNodes: unknown[], idContext: string) => Partial<TData>;\n}\n\n/**\n * App-injected capabilities. Core blocks stay app-agnostic by taking these\n * rather than importing app services — mirroring `createImageExtension`'s\n * `onImageUpload` injection. Provided via `BlockRegistryProvider`.\n */\nexport interface BlockRenderContext {\n /** Markdown dialect for the auto-editor's rich-text field. */\n dialect?: \"gfm\" | \"nfm\";\n /** Resolve an asset id → displayable URL. */\n resolveAssetSrc?: (assetId: string) => string | undefined;\n /** Open the shared asset picker (returns the chosen asset). */\n pickAsset?: () => Promise<{ assetId: string; url?: string } | null>;\n /** Upload a local file, returns a hosted URL. */\n uploadFile?: (file: File) => Promise<{ url: string; assetId?: string }>;\n /** Call an app action by name (for blocks that fetch live data). */\n callAction?: (name: string, args: unknown) => Promise<unknown>;\n /** Sanitizer for HTML-bearing blocks. Provided by the app/core. */\n sanitizeHtml?: (html: string, css?: string) => string;\n /**\n * Render a markdown string with the app's read-only markdown renderer. Lets a\n * core block (whose `Read` lives in core) defer prose rendering to the app's\n * markdown reader (e.g. the plan `PlanMarkdownReader`) without importing it.\n */\n renderMarkdown?: (\n markdown: string,\n options?: { className?: string },\n ) => React.ReactNode;\n /**\n * Static capture mode: render every code/diff line annotation as a visible\n * inline overlay instead of requiring hover.\n */\n showCodeAnnotationOverlays?: boolean;\n /**\n * Optional placement policy for line-anchored code/diff annotations.\n * Hosts can keep the default right-first hover behavior, or ask annotations to\n * prefer a margin side and become persistent whenever that margin has room.\n */\n codeAnnotationLayout?: {\n /** Preferred side for hover cards when that side has a clean gutter. */\n hoverSide?: \"left\" | \"right\";\n /**\n * Final hover fallback when neither side has a clean gutter. `\"below\"` keeps\n * the legacy line-below behavior; `\"left\"`/`\"right\"` clamp the card to that\n * viewport side, even if it overlaps part of the code surface.\n */\n hoverFallbackSide?: \"left\" | \"right\" | \"below\";\n /** Show all annotation cards by default when the requested margin fits. */\n showByDefaultWhenRoom?: boolean;\n /** Margin side for persistent cards; `\"auto\"` tries hoverSide, then the other side. */\n marginSide?: \"left\" | \"right\" | \"auto\";\n };\n /**\n * Render an inline, editable rich-markdown field. The auto-editor calls this\n * for a `markdown()`-tagged field so the app owns the editor wiring (collab,\n * autosave debounce, dialect) rather than core hardcoding it.\n */\n renderMarkdownEditor?: (props: {\n value: string;\n onChange: (next: string) => void;\n editable: boolean;\n blockId?: string;\n className?: string;\n ariaLabel?: string;\n }) => React.ReactNode;\n /**\n * Render an app-owned edit-by-prompt affordance (\"Describe a change…\") for a focused/editable block\n * field. Core block editors pass the current field value and nearby companion\n * fields; the host app decides how to collect the prompt and route it to the\n * agent sidebar. This keeps reusable core blocks from importing app-specific\n * popover/composer code while still exposing a generic AI edit hook.\n */\n renderAiFieldAction?: (props: BlockAiFieldActionProps) => React.ReactNode;\n /**\n * Render a nested child block through the app's own block dispatcher. Container\n * blocks whose `Read`/`Edit` live in core (e.g. tabs) call this to render each\n * child so the recursion keeps flowing through the SAME app renderer the\n * top-level document uses — registered children render via their spec, and\n * unregistered (not-yet-converted) children still fall through the app's legacy\n * switch. This is the coexistence seam: a core container never has to know\n * about app-specific child block types. Returns `null`/`undefined` when no\n * dispatcher is wired (read-only/SSR-only contexts can omit it).\n */\n renderBlock?: (props: {\n block: NestedBlock;\n /** Commit a replacement for this child block (edit mode only). */\n onChange?: (next: NestedBlock) => void;\n /** Whether the parent container is being edited. */\n editing?: boolean;\n /** Tighten embedded visuals in dense contexts (e.g. tab panes). */\n compactVisuals?: boolean;\n }) => React.ReactNode;\n /**\n * Render a nested editable block list through the host app's document editor.\n * Container blocks such as columns call this for each editable region so slash\n * commands, nested structured blocks, and ordinary prose behave like the\n * top-level document while the container still persists its normalized runtime\n * data. Source adapters may still expose a human-friendly nested MDX form\n * (for example `<Columns><Column>markdown</Column></Columns>`) and normalize it\n * into these block arrays at runtime.\n */\n renderBlocksEditor?: (props: {\n blocks: NestedBlock[];\n onChange: (blocks: NestedBlock[]) => void;\n editable: boolean;\n containerBlockId: string;\n regionId: string;\n regionLabel?: string;\n /** Tighten embedded visuals in dense regions such as tab panes. */\n compactVisuals?: boolean;\n }) => React.ReactNode;\n /**\n * Wrap a block's edit form in an app-provided \"panel\" surface (e.g. a shadcn\n * Popover anchored to the corner edit button) for `editSurface: \"panel\"`\n * blocks. Core renders the rendered `Read` view plus a corner trigger button\n * and the form, then hands them here so the app owns the overlay primitive\n * (core stays shadcn-free, mirroring `renderMarkdownEditor`). When omitted, a\n * panel-mode block falls back to inline editing. `title` is the block label.\n */\n renderEditSurface?: (props: {\n title: string;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n trigger: React.ReactNode;\n children: React.ReactNode;\n /** Compact action menus omit host block-edit chrome such as edit-by-prompt. */\n variant?: \"panel\" | \"menu\";\n /** Metadata for host-provided contextual controls such as the edit-by-prompt CTA. */\n blockId?: string;\n blockType?: string;\n blockTitle?: string;\n blockSummary?: string;\n blockData?: unknown;\n }) => React.ReactNode;\n /**\n * Submit a respondent's answers from a `question-form` / `visual-questions`\n * block back to the host. The app decides how to route the summary (e.g. send\n * to the inline agent, copy to clipboard). Core blocks call this through the\n * context so they never import app-specific submit wiring; omit it and the\n * block degrades to a no-op submit.\n */\n onQuestionFormSubmit?: (summary: string) => void;\n}\n\nexport interface BlockAiFieldActionProps {\n blockId: string;\n blockType: string;\n blockTitle?: string;\n blockSummary?: string;\n fieldLabel: string;\n fieldValue: string;\n draftScope: string;\n disabled?: boolean;\n /**\n * Human-readable instructions for the host agent prompt. Mention how to patch\n * the block and which sibling fields should be preserved.\n */\n instructions: string;\n companionFields?: Array<{\n label: string;\n value: string;\n language?: string;\n }>;\n}\n\n/**\n * The minimal shape of a nested child block passed to {@link\n * BlockRenderContext.renderBlock}. It mirrors the app's block union loosely (the\n * app casts it back to its own block type) — a discriminating `type`, a stable\n * `id`, optional heading/summary, and the type-specific `data`.\n */\nexport interface NestedBlock {\n type: string;\n id: string;\n title?: string;\n summary?: string;\n data: unknown;\n [key: string]: unknown;\n}\n\nexport interface BlockContainerRegion {\n id: string;\n label?: string;\n blocks: NestedBlock[];\n}\n\nexport interface BlockContainerSpec<TData> {\n regions: (data: TData) => BlockContainerRegion[];\n updateRegion: (data: TData, regionId: string, blocks: NestedBlock[]) => TData;\n addRegion?: (data: TData, afterRegionId?: string) => TData;\n removeRegion?: (data: TData, regionId: string) => TData;\n reorderRegion?: (\n data: TData,\n fromRegionId: string,\n toRegionId: string,\n ) => TData;\n}\n\nexport type BlockDataChangeMeta = {\n containerRegion?: {\n regionId: string;\n blocks: NestedBlock[];\n };\n};\n\n/** Props passed to a block's read-only renderer. */\nexport interface BlockReadProps<TData> {\n data: TData;\n /** Stable block id (for anchors, comment targeting, source patches). */\n blockId: string;\n /** Block heading, when present. */\n title?: string;\n /** Block trailing summary, when present. */\n summary?: string;\n /** Injected app capabilities. */\n ctx: BlockRenderContext;\n}\n\n/** Props passed to a block's editor (custom or schema-generated). */\nexport interface BlockEditProps<TData> {\n data: TData;\n onChange: (next: TData, meta?: BlockDataChangeMeta) => void;\n editable: boolean;\n blockId: string;\n title?: string;\n summary?: string;\n /** Injected app capabilities. */\n ctx: BlockRenderContext;\n}\n\nexport interface BlockSpec<TData = unknown> {\n /** Discriminator. Equals the runtime block `type`. */\n type: string;\n /** Zod schema for `data`. Drives validation AND the schema-auto-editor. */\n schema: ZodType<TData>;\n /** MDX round-trip config. */\n mdx: BlockMdxConfig<TData>;\n /** Read-only renderer (replaces a `PlanBlockView` switch branch / NodeView). */\n Read: FC<BlockReadProps<TData>>;\n /**\n * Optional editor. When omitted, the registry renders the schema-driven\n * `SchemaBlockEditor` generated from `schema`. Supply for full control\n * (wireframe canvas, diagram editor).\n */\n Edit?: FC<BlockEditProps<TData>>;\n /** Allowed placements: `[\"block\"]`, `[\"inline\"]`, or both. */\n placement: BlockPlacement[];\n /**\n * When `true`, this block's data maps to a Notion-Flavored-Markdown (NFM)\n * analog and therefore round-trips into a Notion page. Apps can derive\n * registry-backed Notion allowlists with\n * {@link BlockRegistry.notionCompatibleTypes} instead of hand-maintaining\n * per-app sets. Set it on registry-atom blocks with an NFM counterpart\n * (checklist, table); leave it `false`/undefined on dev-doc blocks\n * (api-endpoint, openapi-spec, data-model, diff, file-tree, json-explorer,\n * annotated-code, mermaid, custom-html, tabs, code-tabs) and visual/plan-only\n * blocks (wireframe, diagram). Prose blocks that aren't registry atoms\n * (rich-text, callout) carry their NFM analog through the prose path, not this\n * flag.\n */\n notionCompatible?: boolean;\n /**\n * How the block is edited in a `block`-placed document:\n * - `\"inline\"` — the `Edit`/auto-form renders in place for direct\n * manipulation of authored content (prose, checklist text, table cells,\n * code bodies). Schema-ish metadata such as tone/type, tab labels,\n * language, density, or structural settings should still be tucked behind a\n * contextual edit/settings affordance inside the custom `Edit`.\n * - `\"panel\"` — the block shows its rendered `Read` view with a corner edit\n * button that opens the `Edit`/auto-form in an app-provided panel (popover).\n * Best for config-driven blocks whose render differs from their props\n * (custom HTML, charts, any user-registered block).\n * - `\"container\"` — the block renders its `Edit` in place, and that editor\n * may call `ctx.renderBlocksEditor` for nested block regions with normal\n * slash commands and nested structured blocks.\n * Defaults to `\"inline\"` when a custom `Edit` is supplied, else `\"panel\"`\n * (auto-form blocks are property forms, ideal for a panel). The app must wire\n * `ctx.renderEditSurface` for `\"panel\"` to take effect; otherwise it falls\n * back to inline.\n */\n editSurface?: \"inline\" | \"panel\" | \"container\";\n /**\n * Optional generic contract for content-bearing container blocks. Keep this\n * runtime-oriented: it describes editable regions over normalized block arrays;\n * source formats can provide readable nested MDX adapters independently.\n */\n container?: BlockContainerSpec<TData>;\n /** Human label for menus + agent schema export. */\n label: string;\n /** Tabler icon component for UI menus (never emoji/robot/sparkle). */\n icon?: FC<{ size?: number; className?: string }>;\n /** One-line description for the agent schema export. */\n description: string;\n /** Optional default `data` factory for slash-menu insertion (an empty block). */\n empty?: () => TData;\n /**\n * Optional block-specific source-patch handlers, generalizing bespoke ops\n * like `update-custom-html`. Keyed by op name; the registry dispatches a\n * matching patch op here. Generic ops (`update-block` shallow-merge) need none.\n */\n patches?: Record<string, (data: TData, op: Record<string, unknown>) => TData>;\n}\n\n/** Identity helper for authoring a spec with full type inference. */\nexport function defineBlock<TData>(spec: BlockSpec<TData>): BlockSpec<TData> {\n return spec;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/blocks/types.ts"],"names":[],"mappings":"AAqYA,qEAAqE;AACrE,MAAM,UAAU,WAAW,CAAQ,IAAsB;IACvD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { FC } from \"react\";\nimport type { ZodType } from \"zod\";\n\n/**\n * Block-registry contract. A `BlockSpec` describes one document block end to end:\n * its data shape (`schema`), how it round-trips to MDX source (`mdx`), how it\n * renders read-only (`Read`) and how it is edited (`Edit`, or an auto-generated\n * schema-driven editor when omitted), where it can be placed (`placement`), and\n * metadata for menus / agent schema export.\n *\n * The registry runs ALONGSIDE existing per-block code (the plan `PlanBlockView`\n * switch + `serializeBlock`/`parseBlock`). Renderers check the registry first;\n * unregistered block types fall through to the legacy code path unchanged. The\n * MDX `tag` and attribute shape for a converted block MUST match the historical\n * encoding (e.g. `<Callout tone>…body…</Callout>`) so stored `.mdx` files still\n * parse byte-compatibly.\n */\n\n/** Where a block can be placed in a document. */\nexport type BlockPlacement = \"block\" | \"inline\";\n\n/**\n * A serialized MDX/NFM attribute value before the shared `prop()` encoder runs.\n * `prop()` decides string-vs-JSON encoding; this is just the value domain.\n */\nexport type MdxAttrValue =\n | string\n | number\n | boolean\n | unknown[]\n | Record<string, unknown>;\n\n/**\n * Type-narrowed reader over the resolved MDX attributes of a parsed block node.\n * The values are already estree/JSON-resolved by the shared attribute reader\n * (the same engine `plan-mdx.ts` uses), so a spec's `fromAttrs` never touches\n * the AST directly.\n */\nexport interface BlockAttrReader {\n string(name: string): string | undefined;\n number(name: string): number | undefined;\n bool(name: string): boolean | undefined;\n array<T = unknown>(name: string): T[] | undefined;\n object<T = unknown>(name: string): T | undefined;\n raw(name: string): unknown;\n}\n\n/**\n * Maps a block's validated data to/from its MDX component representation.\n * `tag` is the JSX component name in source (e.g. \"Callout\"). It MUST match the\n * historical name in `plan-mdx.ts` `BLOCK_COMPONENTS` / stored `.mdx` files or\n * existing plans break.\n */\nexport interface BlockMdxConfig<TData> {\n /** JSX component name in MDX source. Stable contract — never rename. */\n tag: string;\n /**\n * Encode `data` → a flat attribute bag. The registry serializer runs each\n * value through the shared `prop()` encoder (string-vs-JSON heuristic) and\n * preserves insertion order, so write the keys in the exact historical order.\n * Return `undefined` for a key (or omit it) to drop the attribute. When\n * `childrenField` is set, that field is excluded from the attribute bag.\n */\n toAttrs: (data: TData) => Record<string, MdxAttrValue | undefined>;\n /**\n * Decode resolved attributes (+ optional children markdown) → data. Must\n * tolerate missing/partial attributes for backward-compat (mirror today's\n * `?? []` / `?? \"\"` defaults).\n */\n fromAttrs: (attrs: BlockAttrReader, children: string) => TData;\n /**\n * When set, this data field is a markdown string serialized as MDX *children*\n * between the open/close tags (prose-bearing blocks: rich-text, callout)\n * rather than as a prop — so the body survives as real, inline-editable MDX\n * prose in source.\n */\n childrenField?: keyof TData & string;\n /**\n * Opt-in custom children serializer for blocks whose internals are nested MDX\n * components rather than a single markdown string (e.g. wireframe → Screen/kit\n * primitives). When present it overrides `childrenField`. `serializeChildren`\n * returns the raw inner MDX; `parseChildren` receives the child MDX AST nodes.\n */\n serializeChildren?: (data: TData) => string;\n parseChildren?: (childNodes: unknown[], idContext: string) => Partial<TData>;\n}\n\n/**\n * App-injected capabilities. Core blocks stay app-agnostic by taking these\n * rather than importing app services — mirroring `createImageExtension`'s\n * `onImageUpload` injection. Provided via `BlockRegistryProvider`.\n */\nexport interface BlockRenderContext {\n /** Markdown dialect for the auto-editor's rich-text field. */\n dialect?: \"gfm\" | \"nfm\";\n /** Resolve an asset id → displayable URL. */\n resolveAssetSrc?: (assetId: string) => string | undefined;\n /** Open the shared asset picker (returns the chosen asset). */\n pickAsset?: () => Promise<{ assetId: string; url?: string } | null>;\n /** Upload a local file, returns a hosted URL. */\n uploadFile?: (file: File) => Promise<{ url: string; assetId?: string }>;\n /** Call an app action by name (for blocks that fetch live data). */\n callAction?: (name: string, args: unknown) => Promise<unknown>;\n /** Sanitizer for HTML-bearing blocks. Provided by the app/core. */\n sanitizeHtml?: (html: string, css?: string) => string;\n /**\n * Render a markdown string with the app's read-only markdown renderer. Lets a\n * core block (whose `Read` lives in core) defer prose rendering to the app's\n * markdown reader (e.g. the plan `PlanMarkdownReader`) without importing it.\n */\n renderMarkdown?: (\n markdown: string,\n options?: { className?: string },\n ) => React.ReactNode;\n /**\n * Static capture mode: render every code/diff line annotation as a visible\n * inline overlay instead of requiring hover.\n */\n showCodeAnnotationOverlays?: boolean;\n /**\n * Optional placement policy for line-anchored code/diff annotations.\n * Hosts can keep the default right-first hover behavior, or ask annotations to\n * prefer a margin side and become persistent whenever that margin has room.\n */\n codeAnnotationLayout?: {\n /** Preferred side for hover cards when that side has a clean gutter. */\n hoverSide?: \"left\" | \"right\";\n /**\n * Final hover fallback when neither side has a clean gutter. `\"below\"` keeps\n * the legacy line-below behavior; `\"left\"`/`\"right\"` overlap the card from\n * that code edge with a small overhang.\n */\n hoverFallbackSide?: \"left\" | \"right\" | \"below\";\n /** Show all annotation cards by default when the requested margin fits. */\n showByDefaultWhenRoom?: boolean;\n /** Margin side for persistent cards; `\"auto\"` tries hoverSide, then the other side. */\n marginSide?: \"left\" | \"right\" | \"auto\";\n };\n /**\n * Render an inline, editable rich-markdown field. The auto-editor calls this\n * for a `markdown()`-tagged field so the app owns the editor wiring (collab,\n * autosave debounce, dialect) rather than core hardcoding it.\n */\n renderMarkdownEditor?: (props: {\n value: string;\n onChange: (next: string) => void;\n editable: boolean;\n blockId?: string;\n className?: string;\n ariaLabel?: string;\n }) => React.ReactNode;\n /**\n * Render an app-owned edit-by-prompt affordance (\"Describe a change…\") for a focused/editable block\n * field. Core block editors pass the current field value and nearby companion\n * fields; the host app decides how to collect the prompt and route it to the\n * agent sidebar. This keeps reusable core blocks from importing app-specific\n * popover/composer code while still exposing a generic AI edit hook.\n */\n renderAiFieldAction?: (props: BlockAiFieldActionProps) => React.ReactNode;\n /**\n * Render a nested child block through the app's own block dispatcher. Container\n * blocks whose `Read`/`Edit` live in core (e.g. tabs) call this to render each\n * child so the recursion keeps flowing through the SAME app renderer the\n * top-level document uses — registered children render via their spec, and\n * unregistered (not-yet-converted) children still fall through the app's legacy\n * switch. This is the coexistence seam: a core container never has to know\n * about app-specific child block types. Returns `null`/`undefined` when no\n * dispatcher is wired (read-only/SSR-only contexts can omit it).\n */\n renderBlock?: (props: {\n block: NestedBlock;\n /** Commit a replacement for this child block (edit mode only). */\n onChange?: (next: NestedBlock) => void;\n /** Whether the parent container is being edited. */\n editing?: boolean;\n /** Tighten embedded visuals in dense contexts (e.g. tab panes). */\n compactVisuals?: boolean;\n }) => React.ReactNode;\n /**\n * Render a nested editable block list through the host app's document editor.\n * Container blocks such as columns call this for each editable region so slash\n * commands, nested structured blocks, and ordinary prose behave like the\n * top-level document while the container still persists its normalized runtime\n * data. Source adapters may still expose a human-friendly nested MDX form\n * (for example `<Columns><Column>markdown</Column></Columns>`) and normalize it\n * into these block arrays at runtime.\n */\n renderBlocksEditor?: (props: {\n blocks: NestedBlock[];\n onChange: (blocks: NestedBlock[]) => void;\n editable: boolean;\n containerBlockId: string;\n regionId: string;\n regionLabel?: string;\n /** Tighten embedded visuals in dense regions such as tab panes. */\n compactVisuals?: boolean;\n }) => React.ReactNode;\n /**\n * Wrap a block's edit form in an app-provided \"panel\" surface (e.g. a shadcn\n * Popover anchored to the corner edit button) for `editSurface: \"panel\"`\n * blocks. Core renders the rendered `Read` view plus a corner trigger button\n * and the form, then hands them here so the app owns the overlay primitive\n * (core stays shadcn-free, mirroring `renderMarkdownEditor`). When omitted, a\n * panel-mode block falls back to inline editing. `title` is the block label.\n */\n renderEditSurface?: (props: {\n title: string;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n trigger: React.ReactNode;\n children: React.ReactNode;\n /** Compact action menus omit host block-edit chrome such as edit-by-prompt. */\n variant?: \"panel\" | \"menu\";\n /** Metadata for host-provided contextual controls such as the edit-by-prompt CTA. */\n blockId?: string;\n blockType?: string;\n blockTitle?: string;\n blockSummary?: string;\n blockData?: unknown;\n }) => React.ReactNode;\n /**\n * Submit a respondent's answers from a `question-form` / `visual-questions`\n * block back to the host. The app decides how to route the summary (e.g. send\n * to the inline agent, copy to clipboard). Core blocks call this through the\n * context so they never import app-specific submit wiring; omit it and the\n * block degrades to a no-op submit.\n */\n onQuestionFormSubmit?: (summary: string) => void;\n}\n\nexport interface BlockAiFieldActionProps {\n blockId: string;\n blockType: string;\n blockTitle?: string;\n blockSummary?: string;\n fieldLabel: string;\n fieldValue: string;\n draftScope: string;\n disabled?: boolean;\n /**\n * Human-readable instructions for the host agent prompt. Mention how to patch\n * the block and which sibling fields should be preserved.\n */\n instructions: string;\n companionFields?: Array<{\n label: string;\n value: string;\n language?: string;\n }>;\n}\n\n/**\n * The minimal shape of a nested child block passed to {@link\n * BlockRenderContext.renderBlock}. It mirrors the app's block union loosely (the\n * app casts it back to its own block type) — a discriminating `type`, a stable\n * `id`, optional heading/summary, and the type-specific `data`.\n */\nexport interface NestedBlock {\n type: string;\n id: string;\n title?: string;\n summary?: string;\n data: unknown;\n [key: string]: unknown;\n}\n\nexport interface BlockContainerRegion {\n id: string;\n label?: string;\n blocks: NestedBlock[];\n}\n\nexport interface BlockContainerSpec<TData> {\n regions: (data: TData) => BlockContainerRegion[];\n updateRegion: (data: TData, regionId: string, blocks: NestedBlock[]) => TData;\n addRegion?: (data: TData, afterRegionId?: string) => TData;\n removeRegion?: (data: TData, regionId: string) => TData;\n reorderRegion?: (\n data: TData,\n fromRegionId: string,\n toRegionId: string,\n ) => TData;\n}\n\nexport type BlockDataChangeMeta = {\n containerRegion?: {\n regionId: string;\n blocks: NestedBlock[];\n };\n};\n\n/** Props passed to a block's read-only renderer. */\nexport interface BlockReadProps<TData> {\n data: TData;\n /** Stable block id (for anchors, comment targeting, source patches). */\n blockId: string;\n /** Block heading, when present. */\n title?: string;\n /** Block trailing summary, when present. */\n summary?: string;\n /** Injected app capabilities. */\n ctx: BlockRenderContext;\n}\n\n/** Props passed to a block's editor (custom or schema-generated). */\nexport interface BlockEditProps<TData> {\n data: TData;\n onChange: (next: TData, meta?: BlockDataChangeMeta) => void;\n editable: boolean;\n blockId: string;\n title?: string;\n summary?: string;\n /** Injected app capabilities. */\n ctx: BlockRenderContext;\n}\n\nexport interface BlockSpec<TData = unknown> {\n /** Discriminator. Equals the runtime block `type`. */\n type: string;\n /** Zod schema for `data`. Drives validation AND the schema-auto-editor. */\n schema: ZodType<TData>;\n /** MDX round-trip config. */\n mdx: BlockMdxConfig<TData>;\n /** Read-only renderer (replaces a `PlanBlockView` switch branch / NodeView). */\n Read: FC<BlockReadProps<TData>>;\n /**\n * Optional editor. When omitted, the registry renders the schema-driven\n * `SchemaBlockEditor` generated from `schema`. Supply for full control\n * (wireframe canvas, diagram editor).\n */\n Edit?: FC<BlockEditProps<TData>>;\n /** Allowed placements: `[\"block\"]`, `[\"inline\"]`, or both. */\n placement: BlockPlacement[];\n /**\n * When `true`, this block's data maps to a Notion-Flavored-Markdown (NFM)\n * analog and therefore round-trips into a Notion page. Apps can derive\n * registry-backed Notion allowlists with\n * {@link BlockRegistry.notionCompatibleTypes} instead of hand-maintaining\n * per-app sets. Set it on registry-atom blocks with an NFM counterpart\n * (checklist, table); leave it `false`/undefined on dev-doc blocks\n * (api-endpoint, openapi-spec, data-model, diff, file-tree, json-explorer,\n * annotated-code, mermaid, custom-html, tabs, code-tabs) and visual/plan-only\n * blocks (wireframe, diagram). Prose blocks that aren't registry atoms\n * (rich-text, callout) carry their NFM analog through the prose path, not this\n * flag.\n */\n notionCompatible?: boolean;\n /**\n * How the block is edited in a `block`-placed document:\n * - `\"inline\"` — the `Edit`/auto-form renders in place for direct\n * manipulation of authored content (prose, checklist text, table cells,\n * code bodies). Schema-ish metadata such as tone/type, tab labels,\n * language, density, or structural settings should still be tucked behind a\n * contextual edit/settings affordance inside the custom `Edit`.\n * - `\"panel\"` — the block shows its rendered `Read` view with a corner edit\n * button that opens the `Edit`/auto-form in an app-provided panel (popover).\n * Best for config-driven blocks whose render differs from their props\n * (custom HTML, charts, any user-registered block).\n * - `\"container\"` — the block renders its `Edit` in place, and that editor\n * may call `ctx.renderBlocksEditor` for nested block regions with normal\n * slash commands and nested structured blocks.\n * Defaults to `\"inline\"` when a custom `Edit` is supplied, else `\"panel\"`\n * (auto-form blocks are property forms, ideal for a panel). The app must wire\n * `ctx.renderEditSurface` for `\"panel\"` to take effect; otherwise it falls\n * back to inline.\n */\n editSurface?: \"inline\" | \"panel\" | \"container\";\n /**\n * Optional generic contract for content-bearing container blocks. Keep this\n * runtime-oriented: it describes editable regions over normalized block arrays;\n * source formats can provide readable nested MDX adapters independently.\n */\n container?: BlockContainerSpec<TData>;\n /** Human label for menus + agent schema export. */\n label: string;\n /** Tabler icon component for UI menus (never emoji/robot/sparkle). */\n icon?: FC<{ size?: number; className?: string }>;\n /** One-line description for the agent schema export. */\n description: string;\n /** Optional default `data` factory for slash-menu insertion (an empty block). */\n empty?: () => TData;\n /**\n * Optional block-specific source-patch handlers, generalizing bespoke ops\n * like `update-custom-html`. Keyed by op name; the registry dispatches a\n * matching patch op here. Generic ops (`update-block` shallow-merge) need none.\n */\n patches?: Record<string, (data: TData, op: Record<string, unknown>) => TData>;\n}\n\n/** Identity helper for authoring a spec with full type inference. */\nexport function defineBlock<TData>(spec: BlockSpec<TData>): BlockSpec<TData> {\n return spec;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-code.d.ts","sourceRoot":"","sources":["../../src/coding-tools/run-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AASH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AA8DhE,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAC7C,IAAI,GAAE,cAAmB,GACxB,WAAW,
|
|
1
|
+
{"version":3,"file":"run-code.d.ts","sourceRoot":"","sources":["../../src/coding-tools/run-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AASH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AA8DhE,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAC7C,IAAI,GAAE,cAAmB,GACxB,WAAW,CA2Mb"}
|