@agent-native/core 0.39.2 → 0.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/action.js +12 -0
- package/dist/action.js.map +1 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +5 -1
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/skills.d.ts +4 -3
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +756 -694
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/blocks/AiEditableField.d.ts +8 -0
- package/dist/client/blocks/AiEditableField.d.ts.map +1 -0
- package/dist/client/blocks/AiEditableField.js +10 -0
- package/dist/client/blocks/AiEditableField.js.map +1 -0
- package/dist/client/blocks/BlockView.d.ts +3 -3
- package/dist/client/blocks/BlockView.d.ts.map +1 -1
- package/dist/client/blocks/BlockView.js +15 -3
- package/dist/client/blocks/BlockView.js.map +1 -1
- package/dist/client/blocks/SchemaBlockEditor.js +2 -2
- package/dist/client/blocks/SchemaBlockEditor.js.map +1 -1
- package/dist/client/blocks/index.d.ts +5 -2
- package/dist/client/blocks/index.d.ts.map +1 -1
- package/dist/client/blocks/index.js +6 -3
- package/dist/client/blocks/index.js.map +1 -1
- package/dist/client/blocks/library/ApiEndpointBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/ApiEndpointBlock.js +20 -6
- package/dist/client/blocks/library/ApiEndpointBlock.js.map +1 -1
- package/dist/client/blocks/library/DiffBlock.d.ts +29 -0
- package/dist/client/blocks/library/DiffBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/DiffBlock.js +190 -30
- package/dist/client/blocks/library/DiffBlock.js.map +1 -1
- package/dist/client/blocks/library/FileTreeBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/FileTreeBlock.js +46 -7
- package/dist/client/blocks/library/FileTreeBlock.js.map +1 -1
- package/dist/client/blocks/library/HighlightedCode.d.ts +10 -0
- package/dist/client/blocks/library/HighlightedCode.d.ts.map +1 -0
- package/dist/client/blocks/library/HighlightedCode.js +92 -0
- package/dist/client/blocks/library/HighlightedCode.js.map +1 -0
- package/dist/client/blocks/library/JsonExplorerBlock.d.ts +9 -4
- package/dist/client/blocks/library/JsonExplorerBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/JsonExplorerBlock.js +66 -30
- package/dist/client/blocks/library/JsonExplorerBlock.js.map +1 -1
- package/dist/client/blocks/library/MermaidBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/MermaidBlock.js +73 -44
- package/dist/client/blocks/library/MermaidBlock.js.map +1 -1
- package/dist/client/blocks/library/OpenApiSpecBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/OpenApiSpecBlock.js +3 -2
- package/dist/client/blocks/library/OpenApiSpecBlock.js.map +1 -1
- package/dist/client/blocks/library/checklist.d.ts.map +1 -1
- package/dist/client/blocks/library/checklist.js +1 -0
- package/dist/client/blocks/library/checklist.js.map +1 -1
- package/dist/client/blocks/library/code-tabs.d.ts.map +1 -1
- package/dist/client/blocks/library/code-tabs.js +183 -102
- package/dist/client/blocks/library/code-tabs.js.map +1 -1
- package/dist/client/blocks/library/columns.config.d.ts +60 -0
- package/dist/client/blocks/library/columns.config.d.ts.map +1 -0
- package/dist/client/blocks/library/columns.config.js +37 -0
- package/dist/client/blocks/library/columns.config.js.map +1 -0
- package/dist/client/blocks/library/columns.d.ts +25 -0
- package/dist/client/blocks/library/columns.d.ts.map +1 -0
- package/dist/client/blocks/library/columns.js +199 -0
- package/dist/client/blocks/library/columns.js.map +1 -0
- package/dist/client/blocks/library/dev-doc-ui.d.ts +2 -1
- package/dist/client/blocks/library/dev-doc-ui.d.ts.map +1 -1
- package/dist/client/blocks/library/dev-doc-ui.js +2 -1
- package/dist/client/blocks/library/dev-doc-ui.js.map +1 -1
- package/dist/client/blocks/library/html.d.ts +1 -1
- package/dist/client/blocks/library/html.d.ts.map +1 -1
- package/dist/client/blocks/library/html.js +34 -4
- package/dist/client/blocks/library/html.js.map +1 -1
- package/dist/client/blocks/library/json-explorer.config.d.ts +3 -1
- package/dist/client/blocks/library/json-explorer.config.d.ts.map +1 -1
- package/dist/client/blocks/library/json-explorer.config.js +30 -1
- package/dist/client/blocks/library/json-explorer.config.js.map +1 -1
- package/dist/client/blocks/library/server-specs.d.ts.map +1 -1
- package/dist/client/blocks/library/server-specs.js +13 -3
- package/dist/client/blocks/library/server-specs.js.map +1 -1
- package/dist/client/blocks/library/specs.d.ts +4 -4
- package/dist/client/blocks/library/specs.d.ts.map +1 -1
- package/dist/client/blocks/library/specs.js +21 -16
- package/dist/client/blocks/library/specs.js.map +1 -1
- package/dist/client/blocks/library/table.config.d.ts +3 -0
- package/dist/client/blocks/library/table.config.d.ts.map +1 -1
- package/dist/client/blocks/library/table.config.js +13 -1
- package/dist/client/blocks/library/table.config.js.map +1 -1
- package/dist/client/blocks/library/table.d.ts.map +1 -1
- package/dist/client/blocks/library/table.js +90 -9
- package/dist/client/blocks/library/table.js.map +1 -1
- package/dist/client/blocks/library/tabs.config.d.ts +16 -8
- package/dist/client/blocks/library/tabs.config.d.ts.map +1 -1
- package/dist/client/blocks/library/tabs.config.js +10 -4
- package/dist/client/blocks/library/tabs.config.js.map +1 -1
- package/dist/client/blocks/library/tabs.d.ts.map +1 -1
- package/dist/client/blocks/library/tabs.js +146 -21
- package/dist/client/blocks/library/tabs.js.map +1 -1
- package/dist/client/blocks/server.d.ts +2 -1
- package/dist/client/blocks/server.d.ts.map +1 -1
- package/dist/client/blocks/server.js +1 -0
- package/dist/client/blocks/server.js.map +1 -1
- package/dist/client/blocks/types.d.ts +99 -9
- package/dist/client/blocks/types.d.ts.map +1 -1
- package/dist/client/blocks/types.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -2
- package/dist/client/index.js.map +1 -1
- package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/BubbleToolbar.js +13 -3
- package/dist/client/rich-markdown-editor/BubbleToolbar.js.map +1 -1
- package/dist/client/rich-markdown-editor/DragHandle.d.ts +49 -4
- package/dist/client/rich-markdown-editor/DragHandle.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/DragHandle.js +656 -88
- package/dist/client/rich-markdown-editor/DragHandle.js.map +1 -1
- package/dist/client/rich-markdown-editor/RegistryBlockNode.d.ts +10 -1
- package/dist/client/rich-markdown-editor/RegistryBlockNode.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/RegistryBlockNode.js +180 -15
- package/dist/client/rich-markdown-editor/RegistryBlockNode.js.map +1 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts +2 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.js +3 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.js.map +1 -1
- package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts +5 -0
- package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/SlashCommandMenu.js +33 -5
- package/dist/client/rich-markdown-editor/SlashCommandMenu.js.map +1 -1
- package/dist/client/rich-markdown-editor/index.d.ts +3 -3
- package/dist/client/rich-markdown-editor/index.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/index.js +2 -2
- package/dist/client/rich-markdown-editor/index.js.map +1 -1
- package/dist/client/rich-markdown-editor/registrySlashCommands.d.ts +14 -0
- package/dist/client/rich-markdown-editor/registrySlashCommands.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/registrySlashCommands.js +38 -0
- package/dist/client/rich-markdown-editor/registrySlashCommands.js.map +1 -1
- package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts +1 -0
- package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/useCollabReconcile.js +4 -0
- package/dist/client/rich-markdown-editor/useCollabReconcile.js.map +1 -1
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +17 -1
- package/dist/db/client.js.map +1 -1
- package/dist/deploy/build.js +68 -0
- package/dist/deploy/build.js.map +1 -1
- package/dist/sharing/access.d.ts +4 -2
- package/dist/sharing/access.d.ts.map +1 -1
- package/dist/sharing/access.js +8 -3
- package/dist/sharing/access.js.map +1 -1
- package/dist/sharing/actions/set-resource-visibility.d.ts.map +1 -1
- package/dist/sharing/actions/set-resource-visibility.js +2 -3
- package/dist/sharing/actions/set-resource-visibility.js.map +1 -1
- package/dist/sharing/registry.d.ts +13 -0
- package/dist/sharing/registry.d.ts.map +1 -1
- package/dist/sharing/registry.js.map +1 -1
- package/dist/styles/rich-markdown-editor.css +15 -0
- package/package.json +16 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiEndpointBlock.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/ApiEndpointBlock.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AASpC,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,WAAW,EACX,SAAS,GACV,MAAM,iBAAiB,CAAC;AAEzB;;;;GAIG;AAEH,kFAAkF;AAElF;;;;;GAKG;AACH,MAAM,WAAW,GAAsC;IACrD,GAAG,EAAE,8EAA8E;IACnF,IAAI,EAAE,kEAAkE;IACxE,GAAG,EAAE,sEAAsE;IAC3E,KAAK,EACH,0EAA0E;IAC5E,MAAM,EAAE,8DAA8D;IACtE,IAAI,EAAE,sEAAsE;IAC5E,OAAO,EACL,sEAAsE;CACzE,CAAC;AAEF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} from \"../../utils.js\";\nimport type { BlockEditProps, BlockReadProps } from \"../types.js\";\nimport type {\n ApiEndpointData,\n ApiEndpointMethod,\n ApiEndpointParam,\n ApiEndpointResponse,\n ApiParamLocation,\n} from \"./api-endpoint.config.js\";\nimport {\n API_ENDPOINT_METHODS,\n API_PARAM_LOCATIONS,\n} from \"./api-endpoint.config.js\";\nimport {\n DevBadge,\n DevInput,\n DevSwitch,\n DevTextarea,\n DevSelect,\n} from \"./dev-doc-ui.js\";\n\n/**\n * Read + Edit renderers for an `api-endpoint` block — a Swagger / Stripe-style\n * API reference. Lives in core so any app can register the dev-doc block (no\n * shadcn import).\n */\n\n/* ── Theme-aware color tokens ──────────────────────────────────────────────── */\n\n/**\n * Method-pill palette. Tinted background + saturated text in BOTH modes (the\n * reference HTML hardcoded a dark-only palette — we deliberately avoid that).\n * Each entry keeps legible contrast against the plan surface under `.dark` and\n * light via Tailwind `dark:` variants.\n */\nconst METHOD_PILL: Record<ApiEndpointMethod, string> = {\n GET: \"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300\",\n POST: \"bg-blue-100 text-blue-700 dark:bg-blue-500/15 dark:text-blue-300\",\n PUT: \"bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300\",\n PATCH:\n \"bg-violet-100 text-violet-700 dark:bg-violet-500/15 dark:text-violet-300\",\n DELETE: \"bg-red-100 text-red-700 dark:bg-red-500/15 dark:text-red-300\",\n HEAD: \"bg-slate-200 text-slate-700 dark:bg-slate-500/20 dark:text-slate-300\",\n OPTIONS:\n \"bg-slate-200 text-slate-700 dark:bg-slate-500/20 dark:text-slate-300\",\n};\n\n/** Location-badge palette for the params table `in` column. */\nconst PARAM_IN_BADGE: Record<ApiParamLocation, string> = {\n path: \"bg-violet-100 text-violet-700 dark:bg-violet-500/15 dark:text-violet-300\",\n query: \"bg-blue-100 text-blue-700 dark:bg-blue-500/15 dark:text-blue-300\",\n header:\n \"bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300\",\n body: \"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300\",\n};\n\n/** Status-pill palette keyed by the leading status digit (2xx/3xx/4xx/5xx). */\nfunction statusPillClass(status: string): string {\n const lead = status.trim().charAt(0);\n if (lead === \"2\")\n return \"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300\";\n if (lead === \"4\")\n return \"bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300\";\n if (lead === \"5\")\n return \"bg-red-100 text-red-700 dark:bg-red-500/15 dark:text-red-300\";\n // 3xx and everything else → neutral slate.\n return \"bg-slate-200 text-slate-700 dark:bg-slate-500/20 dark:text-slate-300\";\n}\n\n/** Guess a fence language from a content type so examples highlight nicely. */\nfunction fenceLangForContentType(contentType?: string): string {\n const ct = (contentType ?? \"\").toLowerCase();\n if (ct.includes(\"json\")) return \"json\";\n if (ct.includes(\"xml\") || ct.includes(\"html\")) return \"html\";\n if (ct.includes(\"yaml\") || ct.includes(\"yml\")) return \"yaml\";\n return \"json\";\n}\n\n/** Wrap a raw example string in a fenced code block for `ctx.renderMarkdown`. */\nfunction fence(example: string, lang: string): string {\n // Never let the example's own content break out of the fence.\n const safe = example.replace(/```/g, \"ʼʼʼ\");\n return `\\`\\`\\`${lang}\\n${safe.trim()}\\n\\`\\`\\``;\n}\n\n/* ── Read (collapsed-by-default swagger row) ───────────────────────────────── */\n\n/**\n * Read-only renderer for an `api-endpoint` block. Collapsed by default: a single\n * row with a colored method pill, monospace path, muted summary, and a chevron.\n * Clicking the row expands the full reference (description, params table,\n * request body, responses) — the Swagger / Stripe house style. Every colored\n * element is theme-aware (`dark:` variants), so it reads correctly in both the\n * `.dark` plan theme and light mode.\n */\nexport function ApiEndpointRead({\n data,\n blockId,\n title,\n summary,\n ctx,\n}: BlockReadProps<ApiEndpointData>) {\n const [open, setOpen] = useState(false);\n\n const params = data.params ?? [];\n const responses = data.responses ?? [];\n const hasRequest = Boolean(\n data.request?.example || data.request?.contentType,\n );\n const hasBody =\n Boolean(data.description?.trim()) ||\n params.length > 0 ||\n hasRequest ||\n responses.length > 0 ||\n Boolean(data.auth);\n\n return (\n <section className=\"plan-block\" data-block-id={blockId}>\n {title && <div className=\"plan-block-label\">{title}</div>}\n <div className=\"overflow-hidden rounded-xl border border-plan-line bg-plan-block\">\n {/* Collapsed summary row — the whole row toggles. */}\n <button\n type=\"button\"\n data-plan-interactive\n aria-expanded={open}\n onClick={() => setOpen((value) => !value)}\n className={cn(\n \"flex w-full items-center gap-3 px-4 py-3 text-left transition-colors\",\n \"hover:bg-accent/40\",\n )}\n >\n <IconChevronRight\n className={cn(\n \"size-4 shrink-0 text-plan-muted transition-transform\",\n open && \"rotate-90\",\n )}\n />\n <span\n className={cn(\n \"shrink-0 rounded-md px-2 py-1 font-mono text-xs font-bold uppercase tracking-wide\",\n METHOD_PILL[data.method],\n )}\n >\n {data.method}\n </span>\n <span\n className={cn(\n \"min-w-0 truncate font-mono text-sm font-semibold text-plan-text\",\n data.deprecated && \"text-plan-muted line-through\",\n )}\n >\n {data.path}\n </span>\n {data.deprecated && (\n <DevBadge className=\"shrink-0 border-amber-500/40 text-amber-600 dark:text-amber-300\">\n Deprecated\n </DevBadge>\n )}\n {(data.summary || summary) && (\n <span className=\"ml-1 min-w-0 flex-1 truncate text-sm text-plan-muted\">\n {data.summary || summary}\n </span>\n )}\n {data.auth && (\n <IconLock\n className=\"size-3.5 shrink-0 text-plan-muted\"\n aria-label=\"Requires authentication\"\n />\n )}\n </button>\n\n {/* Expanded body. */}\n {open && hasBody && (\n <div className=\"border-t border-plan-line px-4 py-4\">\n {data.auth && (\n <div className=\"mb-4 flex items-center gap-2 text-xs text-plan-muted\">\n <IconLock className=\"size-3.5 shrink-0\" />\n <span>\n <span className=\"font-medium text-plan-text\">Auth:</span>{\" \"}\n {data.auth}\n </span>\n </div>\n )}\n\n {data.description?.trim() && (\n <div className=\"an-api-endpoint-desc\">\n {ctx.renderMarkdown?.(data.description)}\n </div>\n )}\n\n {params.length > 0 && (\n <div className=\"mt-5\">\n <div className=\"text-xs font-semibold uppercase tracking-wide text-plan-muted\">\n Parameters\n </div>\n <div className=\"mt-2 overflow-hidden rounded-lg border border-plan-line\">\n <table className=\"w-full border-collapse text-sm\">\n <thead>\n <tr className=\"bg-accent/30 text-left text-xs uppercase tracking-wide text-plan-muted\">\n <th className=\"px-3 py-2 font-medium\">Name</th>\n <th className=\"px-3 py-2 font-medium\">In</th>\n <th className=\"px-3 py-2 font-medium\">Type</th>\n <th className=\"px-3 py-2 font-medium\">Required</th>\n <th className=\"px-3 py-2 font-medium\">Description</th>\n </tr>\n </thead>\n <tbody>\n {params.map((param, index) => (\n <tr\n key={`${param.name}-${index}`}\n className=\"border-t border-plan-line align-top\"\n >\n <td className=\"px-3 py-2 font-mono text-xs font-semibold text-plan-text\">\n {param.name}\n </td>\n <td className=\"px-3 py-2\">\n <span\n className={cn(\n \"rounded px-1.5 py-0.5 font-mono text-[11px] font-semibold\",\n PARAM_IN_BADGE[param.in],\n )}\n >\n {param.in}\n </span>\n </td>\n <td className=\"px-3 py-2 font-mono text-xs text-plan-muted\">\n {param.type || \"—\"}\n </td>\n <td className=\"px-3 py-2 text-xs\">\n {param.required ? (\n <span className=\"font-medium text-red-600 dark:text-red-300\">\n required\n </span>\n ) : (\n <span className=\"text-plan-muted\">optional</span>\n )}\n </td>\n <td className=\"px-3 py-2 text-xs text-plan-muted\">\n {param.description || \"—\"}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </div>\n )}\n\n {hasRequest && (\n <div className=\"mt-5\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs font-semibold uppercase tracking-wide text-plan-muted\">\n Request body\n </span>\n {data.request?.contentType && (\n <span className=\"rounded bg-accent/40 px-1.5 py-0.5 font-mono text-[11px] text-plan-muted\">\n {data.request.contentType}\n </span>\n )}\n </div>\n {data.request?.example && (\n <div className=\"mt-2 an-api-endpoint-example\">\n {ctx.renderMarkdown?.(\n fence(\n data.request.example,\n fenceLangForContentType(data.request.contentType),\n ),\n )}\n </div>\n )}\n </div>\n )}\n\n {responses.length > 0 && (\n <div className=\"mt-5\">\n <div className=\"text-xs font-semibold uppercase tracking-wide text-plan-muted\">\n Responses\n </div>\n <div className=\"mt-2 flex flex-col gap-3\">\n {responses.map((response, index) => (\n <div\n key={`${response.status}-${index}`}\n className=\"rounded-lg border border-plan-line\"\n >\n <div className=\"flex items-center gap-2 px-3 py-2\">\n <span\n className={cn(\n \"rounded px-2 py-0.5 font-mono text-xs font-bold\",\n statusPillClass(response.status),\n )}\n >\n {response.status}\n </span>\n {response.description && (\n <span className=\"text-sm text-plan-muted\">\n {response.description}\n </span>\n )}\n </div>\n {response.example && (\n <div className=\"border-t border-plan-line px-3 pb-3 pt-1 an-api-endpoint-example\">\n {ctx.renderMarkdown?.(\n fence(response.example, \"json\"),\n )}\n </div>\n )}\n </div>\n ))}\n </div>\n </div>\n )}\n </div>\n )}\n </div>\n </section>\n );\n}\n\n/* ── Edit (panel form) ─────────────────────────────────────────────────────── */\n\nconst fieldLabelClass = \"text-xs font-medium text-muted-foreground\";\n\n/**\n * Panel editor for an `api-endpoint` block. A property form: method (Select),\n * path/summary/auth (Input), description (Textarea), deprecated (Switch), plus\n * repeatable rows for params and responses (add/remove) and a request-body\n * textarea. Renders BARE content (no `<section>`); the registry's panel surface\n * supplies the popover chrome.\n */\nexport function ApiEndpointEdit({\n data,\n onChange,\n editable,\n}: BlockEditProps<ApiEndpointData>) {\n const params = data.params ?? [];\n const responses = data.responses ?? [];\n\n const patch = (next: Partial<ApiEndpointData>) =>\n onChange({ ...data, ...next });\n\n const updateParam = (index: number, next: Partial<ApiEndpointParam>) =>\n patch({\n params: params.map((param, i) =>\n i === index ? { ...param, ...next } : param,\n ),\n });\n\n const removeParam = (index: number) =>\n patch({ params: params.filter((_, i) => i !== index) });\n\n const addParam = () =>\n patch({\n params: [...params, { name: \"param\", in: \"query\" as ApiParamLocation }],\n });\n\n const updateResponse = (index: number, next: Partial<ApiEndpointResponse>) =>\n patch({\n responses: responses.map((response, i) =>\n i === index ? { ...response, ...next } : response,\n ),\n });\n\n const removeResponse = (index: number) =>\n patch({ responses: responses.filter((_, i) => i !== index) });\n\n const addResponse = () =>\n patch({ responses: [...responses, { status: \"200\" }] });\n\n const updateRequest = (next: Partial<ApiEndpointData[\"request\"]>) => {\n const merged = { ...(data.request ?? {}), ...next };\n const empty = !merged.contentType && !merged.example;\n patch({ request: empty ? undefined : merged });\n };\n\n return (\n <div className=\"flex flex-col gap-4\" data-plan-interactive>\n <div className=\"grid grid-cols-[120px_minmax(0,1fr)] gap-2\">\n <label className=\"flex flex-col gap-1.5\">\n <span className={fieldLabelClass}>Method</span>\n <DevSelect\n className=\"h-9\"\n value={data.method}\n disabled={!editable}\n onValueChange={(value) =>\n patch({ method: value as ApiEndpointMethod })\n }\n options={API_ENDPOINT_METHODS.map((method) => ({\n value: method,\n label: method,\n }))}\n />\n </label>\n <label className=\"flex flex-col gap-1.5\">\n <span className={fieldLabelClass}>Path</span>\n <DevInput\n className=\"h-9 font-mono\"\n value={data.path}\n disabled={!editable}\n placeholder=\"/api/resource\"\n onChange={(event) => patch({ path: event.target.value })}\n />\n </label>\n </div>\n\n <label className=\"flex flex-col gap-1.5\">\n <span className={fieldLabelClass}>Summary</span>\n <DevInput\n className=\"h-9\"\n value={data.summary ?? \"\"}\n disabled={!editable}\n placeholder=\"Short one-line description\"\n onChange={(event) =>\n patch({ summary: event.target.value || undefined })\n }\n />\n </label>\n\n <label className=\"flex flex-col gap-1.5\">\n <span className={fieldLabelClass}>Description (markdown)</span>\n <DevTextarea\n className=\"min-h-[80px]\"\n value={data.description ?? \"\"}\n disabled={!editable}\n placeholder=\"Longer description, rendered as markdown\"\n onChange={(event) =>\n patch({ description: event.target.value || undefined })\n }\n />\n </label>\n\n <div className=\"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-3\">\n <label className=\"flex flex-col gap-1.5\">\n <span className={fieldLabelClass}>Auth</span>\n <DevInput\n className=\"h-9\"\n value={data.auth ?? \"\"}\n disabled={!editable}\n placeholder=\"e.g. Bearer token\"\n onChange={(event) =>\n patch({ auth: event.target.value || undefined })\n }\n />\n </label>\n <label className=\"flex items-center gap-2 pb-2\">\n <DevSwitch\n checked={Boolean(data.deprecated)}\n disabled={!editable}\n onCheckedChange={(checked) =>\n patch({ deprecated: checked || undefined })\n }\n />\n <span className={fieldLabelClass}>Deprecated</span>\n </label>\n </div>\n\n {/* Params */}\n <div className=\"flex flex-col gap-2\">\n <div className=\"flex items-center justify-between\">\n <span className={fieldLabelClass}>Parameters</span>\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n className=\"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground\"\n onClick={addParam}\n >\n <IconPlus className=\"size-3.5\" />\n Add\n </button>\n )}\n </div>\n {params.map((param, index) => (\n <div\n key={index}\n className=\"flex flex-col gap-2 rounded-md border border-input p-2\"\n >\n <div className=\"grid grid-cols-[minmax(0,1fr)_96px_auto] gap-2\">\n <DevInput\n className=\"h-8 font-mono text-xs\"\n value={param.name}\n disabled={!editable}\n placeholder=\"name\"\n onChange={(event) =>\n updateParam(index, { name: event.target.value })\n }\n />\n <DevSelect\n className=\"h-8\"\n value={param.in}\n disabled={!editable}\n onValueChange={(value) =>\n updateParam(index, { in: value as ApiParamLocation })\n }\n options={API_PARAM_LOCATIONS.map((location) => ({\n value: location,\n label: location,\n }))}\n />\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n aria-label=\"Remove parameter\"\n className=\"flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/60 hover:text-foreground\"\n onClick={() => removeParam(index)}\n >\n <IconTrash className=\"size-4\" />\n </button>\n )}\n </div>\n <div className=\"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-2\">\n <DevInput\n className=\"h-8 font-mono text-xs\"\n value={param.type ?? \"\"}\n disabled={!editable}\n placeholder=\"type (e.g. string)\"\n onChange={(event) =>\n updateParam(index, { type: event.target.value || undefined })\n }\n />\n <label className=\"flex items-center gap-1.5 whitespace-nowrap text-xs text-muted-foreground\">\n <input\n type=\"checkbox\"\n className=\"size-3.5 cursor-pointer accent-primary\"\n checked={Boolean(param.required)}\n disabled={!editable}\n onChange={(event) =>\n updateParam(index, {\n required: event.target.checked || undefined,\n })\n }\n />\n Required\n </label>\n </div>\n <DevInput\n className=\"h-8 text-xs\"\n value={param.description ?? \"\"}\n disabled={!editable}\n placeholder=\"description\"\n onChange={(event) =>\n updateParam(index, {\n description: event.target.value || undefined,\n })\n }\n />\n </div>\n ))}\n </div>\n\n {/* Request body */}\n <div className=\"flex flex-col gap-2\">\n <span className={fieldLabelClass}>Request body</span>\n <DevInput\n className=\"h-8 font-mono text-xs\"\n value={data.request?.contentType ?? \"\"}\n disabled={!editable}\n placeholder=\"content type (e.g. application/json)\"\n onChange={(event) =>\n updateRequest({ contentType: event.target.value || undefined })\n }\n />\n <DevTextarea\n className=\"min-h-[80px] font-mono text-xs\"\n value={data.request?.example ?? \"\"}\n disabled={!editable}\n placeholder='{ \"example\": \"request body\" }'\n onChange={(event) =>\n updateRequest({ example: event.target.value || undefined })\n }\n />\n </div>\n\n {/* Responses */}\n <div className=\"flex flex-col gap-2\">\n <div className=\"flex items-center justify-between\">\n <span className={fieldLabelClass}>Responses</span>\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n className=\"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground\"\n onClick={addResponse}\n >\n <IconPlus className=\"size-3.5\" />\n Add\n </button>\n )}\n </div>\n {responses.map((response, index) => (\n <div\n key={index}\n className=\"flex flex-col gap-2 rounded-md border border-input p-2\"\n >\n <div className=\"grid grid-cols-[96px_minmax(0,1fr)_auto] gap-2\">\n <DevInput\n className=\"h-8 font-mono text-xs\"\n value={response.status}\n disabled={!editable}\n placeholder=\"200\"\n onChange={(event) =>\n updateResponse(index, { status: event.target.value })\n }\n />\n <DevInput\n className=\"h-8 text-xs\"\n value={response.description ?? \"\"}\n disabled={!editable}\n placeholder=\"description\"\n onChange={(event) =>\n updateResponse(index, {\n description: event.target.value || undefined,\n })\n }\n />\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n aria-label=\"Remove response\"\n className=\"flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/60 hover:text-foreground\"\n onClick={() => removeResponse(index)}\n >\n <IconTrash className=\"size-4\" />\n </button>\n )}\n </div>\n <DevTextarea\n className=\"min-h-[64px] font-mono text-xs\"\n value={response.example ?? \"\"}\n disabled={!editable}\n placeholder='{ \"example\": \"response body\" }'\n onChange={(event) =>\n updateResponse(index, {\n example: event.target.value || undefined,\n })\n }\n />\n </div>\n ))}\n </div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ApiEndpointBlock.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/ApiEndpointBlock.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AASpC,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,WAAW,EACX,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;;;GAIG;AAEH,kFAAkF;AAElF;;;;;GAKG;AACH,MAAM,WAAW,GAAsC;IACrD,GAAG,EAAE,8EAA8E;IACnF,IAAI,EAAE,kEAAkE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D,QAAQ,IAAI,CACX,iBACE,IAAI,EAAC,QAAQ,+CAEF,iBAAiB,EAC5B,SAAS,EAAC,mHAAmH,EAC7H,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,YAEpC,KAAC,SAAS,IAAC,SAAS,EAAC,QAAQ,GAAG,GACzB,CACV,IACG,EACN,KAAC,WAAW,IACV,SAAS,EAAC,gCAAgC,EAC1C,KAAK,EAAE,QAAQ,CAAC,OAAO,IAAI,EAAE,EAC7B,QAAQ,EAAE,CAAC,QAAQ,EACnB,WAAW,EAAC,gCAAgC,EAC5C,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAClB,cAAc,CAAC,KAAK,EAAE;oCACpB,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,SAAS;iCACzC,CAAC,GAEJ,KA9CG,KAAK,CA+CN,CACP,CAAC,IACE,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useState } from \"react\";\nimport {\n IconChevronRight,\n IconLock,\n IconPlus,\n IconTrash,\n} from \"@tabler/icons-react\";\nimport { cn } from \"../../utils.js\";\nimport type { BlockEditProps, BlockReadProps } from \"../types.js\";\nimport type {\n ApiEndpointData,\n ApiEndpointMethod,\n ApiEndpointParam,\n ApiEndpointResponse,\n ApiParamLocation,\n} from \"./api-endpoint.config.js\";\nimport {\n API_ENDPOINT_METHODS,\n API_PARAM_LOCATIONS,\n} from \"./api-endpoint.config.js\";\nimport { JsonExplorerSurface } from \"./JsonExplorerBlock.js\";\nimport {\n DevBadge,\n DevInput,\n DevSwitch,\n DevTextarea,\n DevSelect,\n} from \"./dev-doc-ui.js\";\nimport { CodeSurface } from \"./HighlightedCode.js\";\n\n/**\n * Read + Edit renderers for an `api-endpoint` block — a Swagger / Stripe-style\n * API reference. Lives in core so any app can register the dev-doc block (no\n * shadcn import).\n */\n\n/* ── Theme-aware color tokens ──────────────────────────────────────────────── */\n\n/**\n * Method-pill palette. Tinted background + saturated text in BOTH modes (the\n * reference HTML hardcoded a dark-only palette — we deliberately avoid that).\n * Each entry keeps legible contrast against the plan surface under `.dark` and\n * light via Tailwind `dark:` variants.\n */\nconst METHOD_PILL: Record<ApiEndpointMethod, string> = {\n GET: \"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300\",\n POST: \"bg-blue-100 text-blue-700 dark:bg-blue-500/15 dark:text-blue-300\",\n PUT: \"bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300\",\n PATCH:\n \"bg-violet-100 text-violet-700 dark:bg-violet-500/15 dark:text-violet-300\",\n DELETE: \"bg-red-100 text-red-700 dark:bg-red-500/15 dark:text-red-300\",\n HEAD: \"bg-slate-200 text-slate-700 dark:bg-slate-500/20 dark:text-slate-300\",\n OPTIONS:\n \"bg-slate-200 text-slate-700 dark:bg-slate-500/20 dark:text-slate-300\",\n};\n\n/** Location-badge palette for the params table `in` column. */\nconst PARAM_IN_BADGE: Record<ApiParamLocation, string> = {\n path: \"bg-violet-100 text-violet-700 dark:bg-violet-500/15 dark:text-violet-300\",\n query: \"bg-blue-100 text-blue-700 dark:bg-blue-500/15 dark:text-blue-300\",\n header:\n \"bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300\",\n body: \"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300\",\n};\n\n/** Status-pill palette keyed by the leading status digit (2xx/3xx/4xx/5xx). */\nfunction statusPillClass(status: string): string {\n const lead = status.trim().charAt(0);\n if (lead === \"2\")\n return \"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300\";\n if (lead === \"4\")\n return \"bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300\";\n if (lead === \"5\")\n return \"bg-red-100 text-red-700 dark:bg-red-500/15 dark:text-red-300\";\n // 3xx and everything else → neutral slate.\n return \"bg-slate-200 text-slate-700 dark:bg-slate-500/20 dark:text-slate-300\";\n}\n\n/** Guess a fence language from a content type so examples highlight nicely. */\nfunction fenceLangForContentType(contentType?: string): string {\n const ct = (contentType ?? \"\").toLowerCase();\n if (ct.includes(\"json\")) return \"json\";\n if (ct.includes(\"xml\") || ct.includes(\"html\")) return \"html\";\n if (ct.includes(\"yaml\") || ct.includes(\"yml\")) return \"yaml\";\n return \"json\";\n}\n\nfunction shouldUseJsonExplorer(example: string, contentType?: string): boolean {\n const ct = (contentType ?? \"\").toLowerCase();\n if (contentType && !ct.includes(\"json\")) return false;\n try {\n JSON.parse(example);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction ApiExample({\n example,\n contentType,\n className,\n}: {\n example: string;\n contentType?: string;\n className?: string;\n}) {\n if (shouldUseJsonExplorer(example, contentType)) {\n return (\n <JsonExplorerSurface\n data={{ json: example, collapsedDepth: 2 }}\n className={className}\n />\n );\n }\n\n return (\n <CodeSurface\n code={example}\n language={fenceLangForContentType(contentType)}\n className={className}\n />\n );\n}\n\n/* ── Read (collapsed-by-default swagger row) ───────────────────────────────── */\n\n/**\n * Read-only renderer for an `api-endpoint` block. Collapsed by default: a single\n * row with a colored method pill, monospace path, muted summary, and a chevron.\n * Clicking the row expands the full reference (description, params table,\n * request body, responses) — the Swagger / Stripe house style. Every colored\n * element is theme-aware (`dark:` variants), so it reads correctly in both the\n * `.dark` plan theme and light mode.\n */\nexport function ApiEndpointRead({\n data,\n blockId,\n title,\n summary,\n ctx,\n}: BlockReadProps<ApiEndpointData>) {\n const [open, setOpen] = useState(false);\n\n const params = data.params ?? [];\n const responses = data.responses ?? [];\n const hasRequest = Boolean(\n data.request?.example || data.request?.contentType,\n );\n const hasBody =\n Boolean(data.description?.trim()) ||\n params.length > 0 ||\n hasRequest ||\n responses.length > 0 ||\n Boolean(data.auth);\n\n return (\n <section className=\"plan-block\" data-block-id={blockId}>\n {title && <div className=\"plan-block-label\">{title}</div>}\n <div className=\"overflow-hidden rounded-xl border border-plan-line bg-plan-block\">\n {/* Collapsed summary row — the whole row toggles. */}\n <button\n type=\"button\"\n data-plan-interactive\n aria-expanded={open}\n onClick={() => setOpen((value) => !value)}\n className={cn(\n \"flex w-full items-center gap-3 px-4 py-3 text-left transition-colors\",\n \"hover:bg-accent/40\",\n )}\n >\n <IconChevronRight\n className={cn(\n \"size-4 shrink-0 text-plan-muted transition-transform\",\n open && \"rotate-90\",\n )}\n />\n <span\n className={cn(\n \"shrink-0 rounded-md px-2 py-1 font-mono text-xs font-bold uppercase tracking-wide\",\n METHOD_PILL[data.method],\n )}\n >\n {data.method}\n </span>\n <span\n className={cn(\n \"min-w-0 truncate font-mono text-sm font-semibold text-plan-text\",\n data.deprecated && \"text-plan-muted line-through\",\n )}\n >\n {data.path}\n </span>\n {data.deprecated && (\n <DevBadge className=\"shrink-0 border-amber-500/40 text-amber-600 dark:text-amber-300\">\n Deprecated\n </DevBadge>\n )}\n {(data.summary || summary) && (\n <span className=\"ml-1 min-w-0 flex-1 truncate text-sm text-plan-muted\">\n {data.summary || summary}\n </span>\n )}\n {data.auth && (\n <IconLock\n className=\"size-3.5 shrink-0 text-plan-muted\"\n aria-label=\"Requires authentication\"\n />\n )}\n </button>\n\n {/* Expanded body. */}\n {open && hasBody && (\n <div className=\"border-t border-plan-line px-4 py-4\">\n {data.auth && (\n <div className=\"mb-4 flex items-center gap-2 text-xs text-plan-muted\">\n <IconLock className=\"size-3.5 shrink-0\" />\n <span>\n <span className=\"font-medium text-plan-text\">Auth:</span>{\" \"}\n {data.auth}\n </span>\n </div>\n )}\n\n {data.description?.trim() && (\n <div className=\"an-api-endpoint-desc\">\n {ctx.renderMarkdown?.(data.description)}\n </div>\n )}\n\n {params.length > 0 && (\n <div className=\"mt-5\">\n <div className=\"text-xs font-semibold uppercase tracking-wide text-plan-muted\">\n Parameters\n </div>\n <div className=\"mt-2 overflow-hidden rounded-lg border border-plan-line\">\n <table className=\"w-full border-collapse text-sm\">\n <thead>\n <tr className=\"bg-accent/30 text-left text-xs uppercase tracking-wide text-plan-muted\">\n <th className=\"px-3 py-2 font-medium\">Name</th>\n <th className=\"px-3 py-2 font-medium\">In</th>\n <th className=\"px-3 py-2 font-medium\">Type</th>\n <th className=\"px-3 py-2 font-medium\">Required</th>\n <th className=\"px-3 py-2 font-medium\">Description</th>\n </tr>\n </thead>\n <tbody>\n {params.map((param, index) => (\n <tr\n key={`${param.name}-${index}`}\n className=\"border-t border-plan-line align-top\"\n >\n <td className=\"px-3 py-2 font-mono text-xs font-semibold text-plan-text\">\n {param.name}\n </td>\n <td className=\"px-3 py-2\">\n <span\n className={cn(\n \"rounded px-1.5 py-0.5 font-mono text-[11px] font-semibold\",\n PARAM_IN_BADGE[param.in],\n )}\n >\n {param.in}\n </span>\n </td>\n <td className=\"px-3 py-2 font-mono text-xs text-plan-muted\">\n {param.type || \"—\"}\n </td>\n <td className=\"px-3 py-2 text-xs\">\n {param.required ? (\n <span className=\"font-medium text-red-600 dark:text-red-300\">\n required\n </span>\n ) : (\n <span className=\"text-plan-muted\">optional</span>\n )}\n </td>\n <td className=\"px-3 py-2 text-xs text-plan-muted\">\n {param.description || \"—\"}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n </div>\n )}\n\n {hasRequest && (\n <div className=\"mt-5\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs font-semibold uppercase tracking-wide text-plan-muted\">\n Request body\n </span>\n {data.request?.contentType && (\n <span className=\"rounded bg-accent/40 px-1.5 py-0.5 font-mono text-[11px] text-plan-muted\">\n {data.request.contentType}\n </span>\n )}\n </div>\n {data.request?.example && (\n <ApiExample\n example={data.request.example}\n contentType={data.request.contentType}\n className=\"mt-2 an-api-endpoint-example\"\n />\n )}\n </div>\n )}\n\n {responses.length > 0 && (\n <div className=\"mt-5\">\n <div className=\"text-xs font-semibold uppercase tracking-wide text-plan-muted\">\n Responses\n </div>\n <div className=\"mt-2 flex flex-col gap-3\">\n {responses.map((response, index) => (\n <div\n key={`${response.status}-${index}`}\n className=\"rounded-lg border border-plan-line\"\n >\n <div className=\"flex items-center gap-2 px-3 py-2\">\n <span\n className={cn(\n \"rounded px-2 py-0.5 font-mono text-xs font-bold\",\n statusPillClass(response.status),\n )}\n >\n {response.status}\n </span>\n {response.description && (\n <span className=\"text-sm text-plan-muted\">\n {response.description}\n </span>\n )}\n </div>\n {response.example && (\n <div className=\"border-t border-plan-line px-3 pb-3 pt-3 an-api-endpoint-example\">\n <ApiExample\n example={response.example}\n className=\"mt-0\"\n />\n </div>\n )}\n </div>\n ))}\n </div>\n </div>\n )}\n </div>\n )}\n </div>\n </section>\n );\n}\n\n/* ── Edit (panel form) ─────────────────────────────────────────────────────── */\n\nconst fieldLabelClass = \"text-xs font-medium text-muted-foreground\";\n\n/**\n * Panel editor for an `api-endpoint` block. A property form: method (Select),\n * path/summary/auth (Input), description (Textarea), deprecated (Switch), plus\n * repeatable rows for params and responses (add/remove) and a request-body\n * textarea. Renders BARE content (no `<section>`); the registry's panel surface\n * supplies the popover chrome.\n */\nexport function ApiEndpointEdit({\n data,\n onChange,\n editable,\n}: BlockEditProps<ApiEndpointData>) {\n const params = data.params ?? [];\n const responses = data.responses ?? [];\n\n const patch = (next: Partial<ApiEndpointData>) =>\n onChange({ ...data, ...next });\n\n const updateParam = (index: number, next: Partial<ApiEndpointParam>) =>\n patch({\n params: params.map((param, i) =>\n i === index ? { ...param, ...next } : param,\n ),\n });\n\n const removeParam = (index: number) =>\n patch({ params: params.filter((_, i) => i !== index) });\n\n const addParam = () =>\n patch({\n params: [...params, { name: \"param\", in: \"query\" as ApiParamLocation }],\n });\n\n const updateResponse = (index: number, next: Partial<ApiEndpointResponse>) =>\n patch({\n responses: responses.map((response, i) =>\n i === index ? { ...response, ...next } : response,\n ),\n });\n\n const removeResponse = (index: number) =>\n patch({ responses: responses.filter((_, i) => i !== index) });\n\n const addResponse = () =>\n patch({ responses: [...responses, { status: \"200\" }] });\n\n const updateRequest = (next: Partial<ApiEndpointData[\"request\"]>) => {\n const merged = { ...(data.request ?? {}), ...next };\n const empty = !merged.contentType && !merged.example;\n patch({ request: empty ? undefined : merged });\n };\n\n return (\n <div className=\"flex flex-col gap-4\" data-plan-interactive>\n <div className=\"grid grid-cols-[120px_minmax(0,1fr)] gap-2\">\n <label className=\"flex flex-col gap-1.5\">\n <span className={fieldLabelClass}>Method</span>\n <DevSelect\n className=\"h-9\"\n value={data.method}\n disabled={!editable}\n onValueChange={(value) =>\n patch({ method: value as ApiEndpointMethod })\n }\n options={API_ENDPOINT_METHODS.map((method) => ({\n value: method,\n label: method,\n }))}\n />\n </label>\n <label className=\"flex flex-col gap-1.5\">\n <span className={fieldLabelClass}>Path</span>\n <DevInput\n className=\"h-9 font-mono\"\n value={data.path}\n disabled={!editable}\n placeholder=\"/api/resource\"\n onChange={(event) => patch({ path: event.target.value })}\n />\n </label>\n </div>\n\n <label className=\"flex flex-col gap-1.5\">\n <span className={fieldLabelClass}>Summary</span>\n <DevInput\n className=\"h-9\"\n value={data.summary ?? \"\"}\n disabled={!editable}\n placeholder=\"Short one-line description\"\n onChange={(event) =>\n patch({ summary: event.target.value || undefined })\n }\n />\n </label>\n\n <label className=\"flex flex-col gap-1.5\">\n <span className={fieldLabelClass}>Description (markdown)</span>\n <DevTextarea\n className=\"min-h-[80px]\"\n value={data.description ?? \"\"}\n disabled={!editable}\n placeholder=\"Longer description, rendered as markdown\"\n onChange={(event) =>\n patch({ description: event.target.value || undefined })\n }\n />\n </label>\n\n <div className=\"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-3\">\n <label className=\"flex flex-col gap-1.5\">\n <span className={fieldLabelClass}>Auth</span>\n <DevInput\n className=\"h-9\"\n value={data.auth ?? \"\"}\n disabled={!editable}\n placeholder=\"e.g. Bearer token\"\n onChange={(event) =>\n patch({ auth: event.target.value || undefined })\n }\n />\n </label>\n <label className=\"flex items-center gap-2 pb-2\">\n <DevSwitch\n checked={Boolean(data.deprecated)}\n disabled={!editable}\n onCheckedChange={(checked) =>\n patch({ deprecated: checked || undefined })\n }\n />\n <span className={fieldLabelClass}>Deprecated</span>\n </label>\n </div>\n\n {/* Params */}\n <div className=\"flex flex-col gap-2\">\n <div className=\"flex items-center justify-between\">\n <span className={fieldLabelClass}>Parameters</span>\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n className=\"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground\"\n onClick={addParam}\n >\n <IconPlus className=\"size-3.5\" />\n Add\n </button>\n )}\n </div>\n {params.map((param, index) => (\n <div\n key={index}\n className=\"flex flex-col gap-2 rounded-md border border-input p-2\"\n >\n <div className=\"grid grid-cols-[minmax(0,1fr)_96px_auto] gap-2\">\n <DevInput\n className=\"h-8 font-mono text-xs\"\n value={param.name}\n disabled={!editable}\n placeholder=\"name\"\n onChange={(event) =>\n updateParam(index, { name: event.target.value })\n }\n />\n <DevSelect\n className=\"h-8\"\n value={param.in}\n disabled={!editable}\n onValueChange={(value) =>\n updateParam(index, { in: value as ApiParamLocation })\n }\n options={API_PARAM_LOCATIONS.map((location) => ({\n value: location,\n label: location,\n }))}\n />\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n aria-label=\"Remove parameter\"\n className=\"flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/60 hover:text-foreground\"\n onClick={() => removeParam(index)}\n >\n <IconTrash className=\"size-4\" />\n </button>\n )}\n </div>\n <div className=\"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-2\">\n <DevInput\n className=\"h-8 font-mono text-xs\"\n value={param.type ?? \"\"}\n disabled={!editable}\n placeholder=\"type (e.g. string)\"\n onChange={(event) =>\n updateParam(index, { type: event.target.value || undefined })\n }\n />\n <label className=\"flex items-center gap-1.5 whitespace-nowrap text-xs text-muted-foreground\">\n <input\n type=\"checkbox\"\n className=\"size-3.5 cursor-pointer accent-primary\"\n checked={Boolean(param.required)}\n disabled={!editable}\n onChange={(event) =>\n updateParam(index, {\n required: event.target.checked || undefined,\n })\n }\n />\n Required\n </label>\n </div>\n <DevInput\n className=\"h-8 text-xs\"\n value={param.description ?? \"\"}\n disabled={!editable}\n placeholder=\"description\"\n onChange={(event) =>\n updateParam(index, {\n description: event.target.value || undefined,\n })\n }\n />\n </div>\n ))}\n </div>\n\n {/* Request body */}\n <div className=\"flex flex-col gap-2\">\n <span className={fieldLabelClass}>Request body</span>\n <DevInput\n className=\"h-8 font-mono text-xs\"\n value={data.request?.contentType ?? \"\"}\n disabled={!editable}\n placeholder=\"content type (e.g. application/json)\"\n onChange={(event) =>\n updateRequest({ contentType: event.target.value || undefined })\n }\n />\n <DevTextarea\n className=\"min-h-[80px] font-mono text-xs\"\n value={data.request?.example ?? \"\"}\n disabled={!editable}\n placeholder='{ \"example\": \"request body\" }'\n onChange={(event) =>\n updateRequest({ example: event.target.value || undefined })\n }\n />\n </div>\n\n {/* Responses */}\n <div className=\"flex flex-col gap-2\">\n <div className=\"flex items-center justify-between\">\n <span className={fieldLabelClass}>Responses</span>\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n className=\"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground\"\n onClick={addResponse}\n >\n <IconPlus className=\"size-3.5\" />\n Add\n </button>\n )}\n </div>\n {responses.map((response, index) => (\n <div\n key={index}\n className=\"flex flex-col gap-2 rounded-md border border-input p-2\"\n >\n <div className=\"grid grid-cols-[96px_minmax(0,1fr)_auto] gap-2\">\n <DevInput\n className=\"h-8 font-mono text-xs\"\n value={response.status}\n disabled={!editable}\n placeholder=\"200\"\n onChange={(event) =>\n updateResponse(index, { status: event.target.value })\n }\n />\n <DevInput\n className=\"h-8 text-xs\"\n value={response.description ?? \"\"}\n disabled={!editable}\n placeholder=\"description\"\n onChange={(event) =>\n updateResponse(index, {\n description: event.target.value || undefined,\n })\n }\n />\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n aria-label=\"Remove response\"\n className=\"flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/60 hover:text-foreground\"\n onClick={() => removeResponse(index)}\n >\n <IconTrash className=\"size-4\" />\n </button>\n )}\n </div>\n <DevTextarea\n className=\"min-h-[64px] font-mono text-xs\"\n value={response.example ?? \"\"}\n disabled={!editable}\n placeholder='{ \"example\": \"response body\" }'\n onChange={(event) =>\n updateResponse(index, {\n example: event.target.value || undefined,\n })\n }\n />\n </div>\n ))}\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
import type { BlockEditProps, BlockReadProps } from "../types.js";
|
|
2
2
|
import type { DiffData } from "./diff.config.js";
|
|
3
|
+
/**
|
|
4
|
+
* GitHub-style before/after diff block. The read renderer computes a line-level
|
|
5
|
+
* diff, then renders it either unified (one column, `+`/`−` gutters) or split
|
|
6
|
+
* (side-by-side). Long unchanged runs collapse into an expandable "N unchanged
|
|
7
|
+
* lines" row (progressive disclosure). The read surface keeps the GitHub diff
|
|
8
|
+
* shape while using the framework Tailwind theme tokens, so it follows each
|
|
9
|
+
* host app's light/dark appearance instead of bringing its own palette.
|
|
10
|
+
*
|
|
11
|
+
* Lives in core so any app can register the dev-doc block. The line differ is
|
|
12
|
+
* inlined (a small LCS-based `diffLines`) rather than pulling the `diff` package
|
|
13
|
+
* into core; the output shape (`{ value, added, removed }` change records) is
|
|
14
|
+
* identical to what the read renderer consumed before.
|
|
15
|
+
*
|
|
16
|
+
* Editing is panel-driven (config-style, like the HTML block): two monospace
|
|
17
|
+
* textareas (Before / After) plus filename, language, and mode controls.
|
|
18
|
+
*/
|
|
19
|
+
interface Change {
|
|
20
|
+
value: string;
|
|
21
|
+
added?: boolean;
|
|
22
|
+
removed?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A minimal line-level diff producing jsdiff-compatible `Change[]` records
|
|
26
|
+
* (`{ value }` for context, `{ value, added: true }`, `{ value, removed: true }`).
|
|
27
|
+
* Uses a classic LCS table over line tokens; the inputs here are short code
|
|
28
|
+
* snippets so the O(n·m) table is fine. Removed lines are emitted before added
|
|
29
|
+
* lines within a change region, matching jsdiff's ordering.
|
|
30
|
+
*/
|
|
31
|
+
export declare function diffLines(before: string, after: string): Change[];
|
|
3
32
|
declare function DiffRead({ data, blockId, title, summary }: BlockReadProps<DiffData>): import("react/jsx-runtime").JSX.Element;
|
|
4
33
|
declare function DiffEdit({ data, onChange, editable }: BlockEditProps<DiffData>): import("react/jsx-runtime").JSX.Element;
|
|
5
34
|
export { DiffRead, DiffEdit };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiffBlock.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/DiffBlock.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DiffBlock.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/DiffBlock.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,kBAAkB,CAAC;AAG3D;;;;;;;;;;;;;;;GAeG;AAIH,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAqBD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAsEjE;AAwTD,iBAAS,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC,2CAqH5E;AAmPD,iBAAS,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC,2CA+EvE;AAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useState } from "react";
|
|
3
|
-
import { IconColumns, IconDotsVertical, IconFileDiff, IconList, } from "@tabler/icons-react";
|
|
3
|
+
import { IconChevronRight, IconColumns, IconDotsVertical, IconFileDiff, IconList, } from "@tabler/icons-react";
|
|
4
|
+
import { common, createLowlight } from "lowlight";
|
|
4
5
|
import { cn } from "../../utils.js";
|
|
5
6
|
import { DevInput, DevLabel, DevTextarea, DevSelect } from "./dev-doc-ui.js";
|
|
6
7
|
/**
|
|
@@ -30,11 +31,18 @@ function toLineTokens(text) {
|
|
|
30
31
|
* snippets so the O(n·m) table is fine. Removed lines are emitted before added
|
|
31
32
|
* lines within a change region, matching jsdiff's ordering.
|
|
32
33
|
*/
|
|
33
|
-
function diffLines(before, after) {
|
|
34
|
+
export function diffLines(before, after) {
|
|
34
35
|
const a = toLineTokens(before);
|
|
35
36
|
const b = toLineTokens(after);
|
|
36
37
|
const n = a.length;
|
|
37
38
|
const m = b.length;
|
|
39
|
+
const cells = (n + 1) * (m + 1);
|
|
40
|
+
if (cells > MAX_DIFF_LCS_CELLS) {
|
|
41
|
+
return [
|
|
42
|
+
...(before ? [{ value: before, removed: true }] : []),
|
|
43
|
+
...(after ? [{ value: after, added: true }] : []),
|
|
44
|
+
];
|
|
45
|
+
}
|
|
38
46
|
// LCS length table.
|
|
39
47
|
const lcs = Array.from({ length: n + 1 }, () => new Array(m + 1).fill(0));
|
|
40
48
|
for (let i = n - 1; i >= 0; i -= 1) {
|
|
@@ -90,6 +98,136 @@ function diffLines(before, after) {
|
|
|
90
98
|
}
|
|
91
99
|
return changes;
|
|
92
100
|
}
|
|
101
|
+
/* ── Syntax highlighting ───────────────────────────────────────────────────── */
|
|
102
|
+
const lowlight = createLowlight(common);
|
|
103
|
+
const LANGUAGE_ALIASES = {
|
|
104
|
+
cjs: "javascript",
|
|
105
|
+
cts: "typescript",
|
|
106
|
+
htm: "html",
|
|
107
|
+
js: "javascript",
|
|
108
|
+
jsonc: "json",
|
|
109
|
+
jsx: "jsx",
|
|
110
|
+
md: "markdown",
|
|
111
|
+
mdx: "markdown",
|
|
112
|
+
mjs: "javascript",
|
|
113
|
+
mts: "typescript",
|
|
114
|
+
py: "python",
|
|
115
|
+
rb: "ruby",
|
|
116
|
+
rs: "rust",
|
|
117
|
+
sh: "bash",
|
|
118
|
+
shell: "bash",
|
|
119
|
+
ts: "typescript",
|
|
120
|
+
tsx: "tsx",
|
|
121
|
+
yml: "yaml",
|
|
122
|
+
zsh: "bash",
|
|
123
|
+
};
|
|
124
|
+
const TOKEN_CLASS_NAMES = {
|
|
125
|
+
"hljs-addition": "text-emerald-700 dark:text-emerald-300",
|
|
126
|
+
"hljs-attr": "text-primary",
|
|
127
|
+
"hljs-attribute": "text-primary",
|
|
128
|
+
"hljs-built_in": "text-amber-700 dark:text-amber-300",
|
|
129
|
+
"hljs-bullet": "text-primary",
|
|
130
|
+
"hljs-comment": "text-muted-foreground italic",
|
|
131
|
+
"hljs-deletion": "text-destructive",
|
|
132
|
+
"hljs-doctag": "text-destructive",
|
|
133
|
+
"hljs-emphasis": "italic",
|
|
134
|
+
"hljs-formula": "text-destructive",
|
|
135
|
+
"hljs-keyword": "text-destructive",
|
|
136
|
+
"hljs-link": "text-primary underline-offset-2",
|
|
137
|
+
"hljs-literal": "text-primary",
|
|
138
|
+
"hljs-meta": "text-primary",
|
|
139
|
+
"hljs-meta-string": "text-emerald-700 dark:text-emerald-300",
|
|
140
|
+
"hljs-name": "text-emerald-700 dark:text-emerald-300",
|
|
141
|
+
"hljs-number": "text-primary",
|
|
142
|
+
"hljs-params": "text-primary",
|
|
143
|
+
"hljs-property": "text-primary",
|
|
144
|
+
"hljs-quote": "text-muted-foreground italic",
|
|
145
|
+
"hljs-regexp": "text-emerald-700 dark:text-emerald-300",
|
|
146
|
+
"hljs-section": "text-violet-700 dark:text-violet-300",
|
|
147
|
+
"hljs-selector-attr": "text-primary",
|
|
148
|
+
"hljs-selector-class": "text-emerald-700 dark:text-emerald-300",
|
|
149
|
+
"hljs-selector-id": "text-emerald-700 dark:text-emerald-300",
|
|
150
|
+
"hljs-selector-pseudo": "text-primary",
|
|
151
|
+
"hljs-selector-tag": "text-emerald-700 dark:text-emerald-300",
|
|
152
|
+
"hljs-string": "text-emerald-700 dark:text-emerald-300",
|
|
153
|
+
"hljs-strong": "font-semibold",
|
|
154
|
+
"hljs-subst": "text-destructive",
|
|
155
|
+
"hljs-symbol": "text-primary",
|
|
156
|
+
"hljs-tag": "text-emerald-700 dark:text-emerald-300",
|
|
157
|
+
"hljs-template-variable": "text-amber-700 dark:text-amber-300",
|
|
158
|
+
"hljs-title": "text-violet-700 dark:text-violet-300",
|
|
159
|
+
"hljs-type": "text-amber-700 dark:text-amber-300",
|
|
160
|
+
"hljs-variable": "text-amber-700 dark:text-amber-300",
|
|
161
|
+
language_: "text-amber-700 dark:text-amber-300",
|
|
162
|
+
};
|
|
163
|
+
function normalizeLanguage(value) {
|
|
164
|
+
const raw = value?.trim().toLowerCase();
|
|
165
|
+
if (!raw)
|
|
166
|
+
return null;
|
|
167
|
+
const normalized = LANGUAGE_ALIASES[raw] ?? raw;
|
|
168
|
+
return lowlight.registered(normalized) ? normalized : null;
|
|
169
|
+
}
|
|
170
|
+
function getLanguageFromFilename(filename) {
|
|
171
|
+
const basename = filename?.split("/").pop()?.toLowerCase();
|
|
172
|
+
if (!basename)
|
|
173
|
+
return null;
|
|
174
|
+
if (basename === "dockerfile")
|
|
175
|
+
return normalizeLanguage("bash");
|
|
176
|
+
if (basename === "makefile")
|
|
177
|
+
return normalizeLanguage("makefile");
|
|
178
|
+
const ext = basename.includes(".") ? basename.split(".").pop() : basename;
|
|
179
|
+
return normalizeLanguage(ext);
|
|
180
|
+
}
|
|
181
|
+
function resolveDiffLanguage(data) {
|
|
182
|
+
return (normalizeLanguage(data.language) ??
|
|
183
|
+
getLanguageFromFilename(data.filename) ??
|
|
184
|
+
"plaintext");
|
|
185
|
+
}
|
|
186
|
+
function tokenClassName(className) {
|
|
187
|
+
const classes = Array.isArray(className)
|
|
188
|
+
? className
|
|
189
|
+
: className
|
|
190
|
+
? className.split(/\s+/)
|
|
191
|
+
: [];
|
|
192
|
+
const mapped = classes
|
|
193
|
+
.map((name) => TOKEN_CLASS_NAMES[name])
|
|
194
|
+
.filter(Boolean)
|
|
195
|
+
.join(" ");
|
|
196
|
+
return mapped || undefined;
|
|
197
|
+
}
|
|
198
|
+
function hastToReact(children, keyPrefix) {
|
|
199
|
+
return children.map((node, index) => {
|
|
200
|
+
if (node.type === "text")
|
|
201
|
+
return node.value ?? "";
|
|
202
|
+
if (node.type === "element") {
|
|
203
|
+
const key = `${keyPrefix}${index}`;
|
|
204
|
+
const renderedChildren = node.children?.length
|
|
205
|
+
? hastToReact(node.children, `${key}-`)
|
|
206
|
+
: null;
|
|
207
|
+
const className = tokenClassName(node.properties?.className);
|
|
208
|
+
if (className) {
|
|
209
|
+
return (_jsx("span", { className: className, children: renderedChildren }, key));
|
|
210
|
+
}
|
|
211
|
+
return _jsx("span", { children: renderedChildren }, key);
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function SyntaxHighlightedLine({ code, language, }) {
|
|
217
|
+
const highlighted = useMemo(() => {
|
|
218
|
+
if (!code.trim() || language === "plaintext" || language === "text") {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
try {
|
|
222
|
+
const tree = lowlight.highlight(language, code);
|
|
223
|
+
return hastToReact(tree.children ?? [], `${language}-`);
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
}, [code, language]);
|
|
229
|
+
return _jsx(_Fragment, { children: highlighted ?? code });
|
|
230
|
+
}
|
|
93
231
|
/** Number of context lines above which an unchanged run is collapsed. */
|
|
94
232
|
const COLLAPSE_THRESHOLD = 6;
|
|
95
233
|
/** Context lines kept visible at each edge of a collapsed run. */
|
|
@@ -172,34 +310,56 @@ function segmentRows(rows) {
|
|
|
172
310
|
}
|
|
173
311
|
/* ── Theme-aware row styling (light + dark) ────────────────────────────────── */
|
|
174
312
|
const ROW_BG = {
|
|
175
|
-
added: "bg-emerald-500/10 dark:bg-emerald-
|
|
176
|
-
removed: "bg-
|
|
177
|
-
context: "",
|
|
313
|
+
added: "bg-emerald-500/10 dark:bg-emerald-500/15",
|
|
314
|
+
removed: "bg-destructive/10",
|
|
315
|
+
context: "bg-background",
|
|
178
316
|
};
|
|
179
317
|
const GUTTER_BG = {
|
|
180
|
-
added: "bg-emerald-500/15 dark:bg-emerald-
|
|
181
|
-
removed: "bg-
|
|
182
|
-
context: "bg-
|
|
318
|
+
added: "bg-emerald-500/15 dark:bg-emerald-500/20",
|
|
319
|
+
removed: "bg-destructive/15",
|
|
320
|
+
context: "bg-muted/60",
|
|
183
321
|
};
|
|
184
322
|
const SIGN_COLOR = {
|
|
185
323
|
added: "text-emerald-700 dark:text-emerald-300",
|
|
186
|
-
removed: "text-
|
|
187
|
-
context: "text-
|
|
324
|
+
removed: "text-destructive",
|
|
325
|
+
context: "text-muted-foreground",
|
|
188
326
|
};
|
|
189
327
|
const SIGN = {
|
|
190
328
|
added: "+",
|
|
191
329
|
removed: "−",
|
|
192
330
|
context: " ",
|
|
193
331
|
};
|
|
194
|
-
const LINE_NO_CLASS = "select-none px-2 text-right font-mono text-[
|
|
332
|
+
const LINE_NO_CLASS = "select-none px-2 py-0 text-right font-mono text-[12px] leading-5 text-muted-foreground tabular-nums";
|
|
333
|
+
const DIFF_LINE_CLASS = "block min-w-max flex-1 whitespace-pre px-2 py-0 font-mono text-[12px] leading-5 text-foreground";
|
|
334
|
+
const DEFAULT_VISIBLE_DIFF_LINES = 15;
|
|
335
|
+
const MAX_DIFF_LCS_CELLS = 1_000_000;
|
|
336
|
+
function splitDiffFilename(filename) {
|
|
337
|
+
const value = filename?.trim() || "diff";
|
|
338
|
+
const segments = value.split("/").filter(Boolean);
|
|
339
|
+
const basename = segments[segments.length - 1] ?? value;
|
|
340
|
+
const directory = segments.length > 1 ? segments.slice(0, -1).join("/") : null;
|
|
341
|
+
return { basename, directory };
|
|
342
|
+
}
|
|
343
|
+
function DiffLineText({ language, text }) {
|
|
344
|
+
const code = text || " ";
|
|
345
|
+
return (_jsx("span", { className: DIFF_LINE_CLASS, children: _jsx(SyntaxHighlightedLine, { code: code, language: language }) }));
|
|
346
|
+
}
|
|
195
347
|
/* ── Read ──────────────────────────────────────────────────────────────────── */
|
|
196
348
|
function DiffRead({ data, blockId, title, summary }) {
|
|
197
349
|
const [mode, setMode] = useState(data.mode ?? "unified");
|
|
198
350
|
const [expanded, setExpanded] = useState(() => new Set());
|
|
351
|
+
const [showAllRows, setShowAllRows] = useState(false);
|
|
199
352
|
const rows = useMemo(() => buildRows(diffLines(data.before, data.after)), [data.before, data.after]);
|
|
353
|
+
const language = useMemo(() => resolveDiffLanguage(data), [data.filename, data.language]);
|
|
354
|
+
const fileParts = useMemo(() => splitDiffFilename(data.filename), [data.filename]);
|
|
355
|
+
const splitLineCount = useMemo(() => pairSplitRows(rows).length, [rows]);
|
|
200
356
|
const added = rows.filter((r) => r.kind === "added").length;
|
|
201
357
|
const removed = rows.filter((r) => r.kind === "removed").length;
|
|
202
358
|
const unchanged = data.before === data.after;
|
|
359
|
+
const totalVisibleLineCount = mode === "split" ? splitLineCount : rows.length;
|
|
360
|
+
const shouldLimitRows = totalVisibleLineCount > DEFAULT_VISIBLE_DIFF_LINES;
|
|
361
|
+
const rowLimit = !showAllRows && shouldLimitRows ? DEFAULT_VISIBLE_DIFF_LINES : undefined;
|
|
362
|
+
const displayedRows = mode === "unified" && rowLimit ? rows.slice(0, rowLimit) : rows;
|
|
203
363
|
const toggleRun = (index) => setExpanded((prev) => {
|
|
204
364
|
const next = new Set(prev);
|
|
205
365
|
if (next.has(index))
|
|
@@ -208,32 +368,34 @@ function DiffRead({ data, blockId, title, summary }) {
|
|
|
208
368
|
next.add(index);
|
|
209
369
|
return next;
|
|
210
370
|
});
|
|
211
|
-
return (_jsxs("section", { className: "plan-block", "data-block-id": blockId, children: [title && _jsx("div", { className: "plan-block-label", children: title }), _jsxs("div", { className: "overflow-hidden rounded-
|
|
371
|
+
return (_jsxs("section", { className: "plan-block group/diff-block", "data-block-id": blockId, children: [title && _jsx("div", { className: "plan-block-label", children: title }), _jsxs("div", { className: "overflow-hidden rounded-md border border-border bg-background", children: [_jsxs("div", { className: "flex min-h-10 flex-wrap items-center gap-2 border-b border-border bg-muted/60 px-3 py-1.5", children: [_jsx(IconFileDiff, { className: "size-4 shrink-0 text-muted-foreground" }), _jsxs("span", { className: "flex min-w-0 flex-1 items-baseline gap-1.5 font-mono", title: data.filename || undefined, children: [_jsx("span", { className: "min-w-0 max-w-[16rem] truncate text-[13px] font-semibold leading-5 text-foreground", children: fileParts.basename }), fileParts.directory && (_jsx("span", { className: "min-w-0 flex-1 truncate text-[11px] leading-5 text-muted-foreground/70", children: fileParts.directory }))] }), _jsxs("span", { className: "ml-1 flex shrink-0 items-center gap-2 font-mono text-xs", children: [_jsxs("span", { className: "text-emerald-700 dark:text-emerald-300", children: ["+", added] }), _jsxs("span", { className: "text-destructive", children: ["\u2212", removed] })] }), _jsxs("div", { className: "pointer-events-none ml-auto flex shrink-0 items-center overflow-hidden rounded-md border border-border bg-background opacity-0 transition-opacity group-hover/diff-block:pointer-events-auto group-hover/diff-block:opacity-100 group-focus-within/diff-block:pointer-events-auto group-focus-within/diff-block:opacity-100", children: [_jsx(ModeButton, { active: mode === "unified", onClick: () => setMode("unified"), icon: _jsx(IconList, { className: "size-3.5" }), label: "Unified" }), _jsx(ModeButton, { active: mode === "split", onClick: () => setMode("split"), icon: _jsx(IconColumns, { className: "size-3.5" }), label: "Split" })] })] }), unchanged ? (_jsx("div", { className: "px-4 py-6 text-center font-mono text-sm text-muted-foreground", children: "No changes" })) : mode === "split" ? (_jsx(SplitView, { rows: rows, language: language, rowLimit: rowLimit })) : (_jsx(UnifiedView, { rows: displayedRows, language: language, expanded: expanded, onToggleRun: toggleRun })), !unchanged && shouldLimitRows && (_jsxs("button", { type: "button", "data-plan-interactive": true, "aria-expanded": showAllRows, onClick: () => setShowAllRows((current) => !current), className: "flex h-7 w-full items-center justify-center gap-1.5 border-t border-border bg-background px-2 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground", children: [_jsx(IconChevronRight, { className: cn("size-3 shrink-0 transition-transform", showAllRows ? "-rotate-90" : "rotate-90") }), showAllRows
|
|
372
|
+
? "Show fewer"
|
|
373
|
+
: `Show all ${totalVisibleLineCount} lines`] }))] }), summary && _jsx("p", { className: "mt-5 text-plan-muted", children: summary })] }));
|
|
212
374
|
}
|
|
213
375
|
function ModeButton({ active, onClick, icon, label, }) {
|
|
214
376
|
return (_jsxs("button", { type: "button", "data-plan-interactive": true, onClick: onClick, "aria-pressed": active, className: cn("flex cursor-pointer items-center gap-1 px-2 py-1 text-xs font-medium transition-colors", active
|
|
215
|
-
? "bg-
|
|
216
|
-
: "text-
|
|
377
|
+
? "bg-accent text-accent-foreground"
|
|
378
|
+
: "text-muted-foreground hover:bg-muted/80 hover:text-foreground"), children: [icon, label] }));
|
|
217
379
|
}
|
|
218
380
|
/* ── Unified view ──────────────────────────────────────────────────────────── */
|
|
219
|
-
function UnifiedView({ rows, expanded, onToggleRun, }) {
|
|
381
|
+
function UnifiedView({ rows, language, expanded, onToggleRun, }) {
|
|
220
382
|
const segments = useMemo(() => segmentRows(rows), [rows]);
|
|
221
383
|
let runIndex = 0;
|
|
222
|
-
return (_jsx("div", { className: "overflow-x-auto", children: _jsx("div", { className: "min-w-full font-mono text-[13px] leading-5", children: segments.map((segment, idx) => {
|
|
384
|
+
return (_jsx("div", { className: "overflow-x-auto", children: _jsx("div", { className: "w-max min-w-full font-mono text-[13px] leading-5", children: segments.map((segment, idx) => {
|
|
223
385
|
if ("collapsed" in segment) {
|
|
224
386
|
const key = runIndex++;
|
|
225
387
|
const open = expanded.has(key);
|
|
226
388
|
return (_jsxs("div", { children: [_jsx(CollapsedRow, { count: segment.rows.length, open: open, onClick: () => onToggleRun(key) }), open &&
|
|
227
|
-
segment.rows.map((row, ri) => (_jsx(UnifiedRow, { row: row }, `run-${key}-${ri}`)))] }, `run-${key}`));
|
|
389
|
+
segment.rows.map((row, ri) => (_jsx(UnifiedRow, { row: row, language: language }, `run-${key}-${ri}`)))] }, `run-${key}`));
|
|
228
390
|
}
|
|
229
|
-
return _jsx(UnifiedRow, { row: segment }, idx);
|
|
391
|
+
return _jsx(UnifiedRow, { row: segment, language: language }, idx);
|
|
230
392
|
}) }) }));
|
|
231
393
|
}
|
|
232
|
-
function UnifiedRow({ row }) {
|
|
233
|
-
return (_jsxs("div", { className: cn("flex w-full", ROW_BG[row.kind]), children: [_jsx("span", { className: cn(LINE_NO_CLASS, "w-
|
|
394
|
+
function UnifiedRow({ language, row }) {
|
|
395
|
+
return (_jsxs("div", { className: cn("flex min-h-5 min-w-full", ROW_BG[row.kind]), children: [_jsx("span", { className: cn(LINE_NO_CLASS, "w-[52px]"), children: row.oldNo ?? "" }), _jsx("span", { className: cn(LINE_NO_CLASS, "w-[52px]"), children: row.newNo ?? "" }), _jsx("span", { className: cn("w-6 shrink-0 select-none py-0 text-center font-semibold leading-5", GUTTER_BG[row.kind], SIGN_COLOR[row.kind]), children: SIGN[row.kind] }), _jsx(DiffLineText, { text: row.text, language: language })] }));
|
|
234
396
|
}
|
|
235
397
|
function CollapsedRow({ count, open, onClick, }) {
|
|
236
|
-
return (_jsxs("button", { type: "button", "data-plan-interactive": true, onClick: onClick, className: "flex w-full cursor-pointer items-center gap-2 border-y border-
|
|
398
|
+
return (_jsxs("button", { type: "button", "data-plan-interactive": true, onClick: onClick, className: "flex w-full cursor-pointer items-center gap-2 border-y border-border bg-muted/70 px-3 py-1 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground", children: [_jsx(IconDotsVertical, { className: "size-3.5 shrink-0" }), _jsxs("span", { children: [open ? "Hide" : "Show", " ", count, " unchanged line", count === 1 ? "" : "s"] })] }));
|
|
237
399
|
}
|
|
238
400
|
/**
|
|
239
401
|
* Pair removed lines (left) with added lines (right) so a modification shows the
|
|
@@ -264,20 +426,18 @@ function pairSplitRows(rows) {
|
|
|
264
426
|
}
|
|
265
427
|
return out;
|
|
266
428
|
}
|
|
267
|
-
function SplitView({ rows }) {
|
|
429
|
+
function SplitView({ language, rowLimit, rows, }) {
|
|
268
430
|
const pairs = useMemo(() => pairSplitRows(rows), [rows]);
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
function SplitRowView({ pair }) {
|
|
272
|
-
return (_jsxs(_Fragment, { children: [_jsx(SplitCell, { row: pair.left, side: "old" }), _jsx(SplitCell, { row: pair.right, side: "new" })] }));
|
|
431
|
+
const displayedPairs = rowLimit ? pairs.slice(0, rowLimit) : pairs;
|
|
432
|
+
return (_jsxs("div", { className: "flex w-full bg-background font-mono text-[12px] leading-5", children: [_jsx("div", { className: "min-w-0 flex-1 overflow-x-auto border-r border-border", children: _jsx("div", { className: "inline-block min-w-full", children: displayedPairs.map((pair, idx) => (_jsx(SplitCell, { row: pair.left, side: "old", language: language }, `old-${idx}`))) }) }), _jsx("div", { className: "min-w-0 flex-1 overflow-x-auto", children: _jsx("div", { className: "inline-block min-w-full", children: displayedPairs.map((pair, idx) => (_jsx(SplitCell, { row: pair.right, side: "new", language: language }, `new-${idx}`))) }) })] }));
|
|
273
433
|
}
|
|
274
|
-
function SplitCell({ row, side }) {
|
|
434
|
+
function SplitCell({ language, row, side, }) {
|
|
275
435
|
if (!row) {
|
|
276
|
-
return (
|
|
436
|
+
return (_jsxs("div", { className: "flex min-h-5 min-w-full bg-muted/40 opacity-70", children: [_jsx("span", { className: cn(LINE_NO_CLASS, "w-[52px]") }), _jsx("span", { className: "w-6 shrink-0 bg-muted/60" }), _jsx("span", { className: DIFF_LINE_CLASS, children: " " })] }));
|
|
277
437
|
}
|
|
278
438
|
const sign = side === "old" ? "−" : "+";
|
|
279
439
|
const showSign = row.kind !== "context";
|
|
280
|
-
return (_jsxs("div", { className: cn("flex", ROW_BG[row.kind]
|
|
440
|
+
return (_jsxs("div", { className: cn("flex min-h-5 min-w-full", ROW_BG[row.kind]), children: [_jsx("span", { className: cn(LINE_NO_CLASS, "w-[52px]"), children: side === "old" ? (row.oldNo ?? "") : (row.newNo ?? "") }), _jsx("span", { className: cn("w-6 shrink-0 select-none py-0 text-center font-semibold leading-5", GUTTER_BG[row.kind], SIGN_COLOR[row.kind]), children: showSign ? sign : " " }), _jsx(DiffLineText, { text: row.text, language: language })] }));
|
|
281
441
|
}
|
|
282
442
|
/* ── Edit (panel) ──────────────────────────────────────────────────────────── */
|
|
283
443
|
const codeAreaClass = "min-h-[140px] font-mono text-xs leading-5";
|