@agent-native/core 0.39.2 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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/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
|
@@ -8,6 +8,7 @@ import { tableSchema, tableMdx } from "./table.config.js";
|
|
|
8
8
|
import { codeTabsSchema, codeTabsMdx, } from "./code-tabs.config.js";
|
|
9
9
|
import { htmlSchema, htmlMdx } from "./html.config.js";
|
|
10
10
|
import { tabsSchema, tabsMdx } from "./tabs.config.js";
|
|
11
|
+
import { columnsSchema, columnsMdx, } from "./columns.config.js";
|
|
11
12
|
import { mermaidSchema, mermaidMdx, } from "./mermaid.config.js";
|
|
12
13
|
import { apiEndpointSchema, apiEndpointMdx, } from "./api-endpoint.config.js";
|
|
13
14
|
import { openApiSpecSchema, openApiSpecMdx, } from "./openapi-spec.config.js";
|
|
@@ -78,7 +79,16 @@ export const libraryBlockConfigs = [
|
|
|
78
79
|
Read: ServerReadStub,
|
|
79
80
|
placement: ["block", "inline"],
|
|
80
81
|
label: "Tabs",
|
|
81
|
-
description: "A
|
|
82
|
+
description: "A top or side tab container; each tab holds its own list of blocks.",
|
|
83
|
+
}),
|
|
84
|
+
defineBlock({
|
|
85
|
+
type: "columns",
|
|
86
|
+
schema: columnsSchema,
|
|
87
|
+
mdx: columnsMdx,
|
|
88
|
+
Read: ServerReadStub,
|
|
89
|
+
placement: ["block"],
|
|
90
|
+
label: "Columns",
|
|
91
|
+
description: "A multi-column side-by-side layout container; each column holds its own list of blocks. Ideal for before/after or current/target comparisons.",
|
|
82
92
|
}),
|
|
83
93
|
defineBlock({
|
|
84
94
|
type: "mermaid",
|
|
@@ -105,7 +115,7 @@ export const libraryBlockConfigs = [
|
|
|
105
115
|
Read: ServerReadStub,
|
|
106
116
|
placement: ["block"],
|
|
107
117
|
label: "OpenAPI spec",
|
|
108
|
-
description: "A whole-document Redoc / Swagger-UI-style API reference rendered from a complete OpenAPI 3 / Swagger 2 spec (JSON).",
|
|
118
|
+
description: "A whole-document API specification / Redoc / Swagger-UI-style API reference rendered from a complete OpenAPI 3 / Swagger 2 spec (JSON).",
|
|
109
119
|
}),
|
|
110
120
|
defineBlock({
|
|
111
121
|
type: "data-model",
|
|
@@ -114,7 +124,7 @@ export const libraryBlockConfigs = [
|
|
|
114
124
|
Read: ServerReadStub,
|
|
115
125
|
placement: ["block"],
|
|
116
126
|
label: "Data model",
|
|
117
|
-
description: "
|
|
127
|
+
description: "A schema modeling / ERD / dbdiagram-style data model: entity cards with typed fields (PK/FK/nullable flags) and interactive foreign-key relations.",
|
|
118
128
|
}),
|
|
119
129
|
defineBlock({
|
|
120
130
|
type: "diff",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-specs.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/server-specs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAsB,MAAM,gBAAgB,CAAC;AAEpE,8EAA8E;AAC9E,iFAAiF;AACjF,iFAAiF;AACjF,OAAO,EACL,eAAe,EACf,YAAY,GAEb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAkB,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EACL,cAAc,EACd,WAAW,GAEZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,OAAO,EAAsB,MAAM,kBAAkB,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E,CAAC;IAC1C,MAAM,KAAK,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC7C,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtC,OAAO,QAAQ,CAAC,CAAC,CAAE,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAqB,CAAC,CAAC,CAAC,IAAI,CAAC;IACxE,CAAC,CAAC,CAAC;IACH,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import { defineBlock, type BlockSpec } from \"../types.js\";\nimport { registerBlocks, type BlockRegistry } from \"../registry.js\";\n\n// React-free schema + MDX config for the standard library. The matching React\n// `Read`/`Edit` live in the full client entry; the server path only ever touches\n// `spec.schema` / `spec.mdx`, so these configs register with a render-only stub.\nimport {\n checklistSchema,\n checklistMdx,\n type ChecklistData,\n} from \"./checklist.config.js\";\nimport { tableSchema, tableMdx, type TableData } from \"./table.config.js\";\nimport {\n codeTabsSchema,\n codeTabsMdx,\n type CodeTabsData,\n} from \"./code-tabs.config.js\";\nimport { htmlSchema, htmlMdx, type HtmlBlockData } from \"./html.config.js\";\nimport { tabsSchema, tabsMdx, type TabsData } from \"./tabs.config.js\";\nimport {\n mermaidSchema,\n mermaidMdx,\n type MermaidData,\n} from \"./mermaid.config.js\";\nimport {\n apiEndpointSchema,\n apiEndpointMdx,\n type ApiEndpointData,\n} from \"./api-endpoint.config.js\";\nimport {\n openApiSpecSchema,\n openApiSpecMdx,\n type OpenApiSpecData,\n} from \"./openapi-spec.config.js\";\nimport {\n dataModelSchema,\n dataModelMdx,\n type DataModelData,\n} from \"./data-model.config.js\";\nimport { diffSchema, diffMdx, type DiffData } from \"./diff.config.js\";\nimport {\n fileTreeSchema,\n fileTreeMdx,\n type FileTreeData,\n} from \"./file-tree.config.js\";\nimport {\n jsonExplorerSchema,\n jsonExplorerMdx,\n type JsonExplorerData,\n} from \"./json-explorer.config.js\";\nimport {\n annotatedCodeSchema,\n annotatedCodeMdx,\n type AnnotatedCodeData,\n} from \"./annotated-code.config.js\";\n\n/** Render-only stub for server / agent registries (never invoked off-browser). */\nconst ServerReadStub = () => null;\n\n/**\n * Canonical React-free specs for the standard library, used by BOTH apps' server\n * / shared registries (`plan-block-registry.ts`, `nfm-registry.ts`). Each carries\n * only the parts the server path touches — `schema` + `mdx` + metadata for the\n * agent schema export — with a render-only `Read` stub. The full client specs\n * (with real React `Read`/`Edit`) live in `./specs.tsx`; both share the identical\n * `schema`/`mdx` config so inline source can never drift from what renders.\n *\n * `table` keeps the core default `type` here; content's server registry renames\n * it to `table-block` via {@link LibraryBlockConfigOverrides}. The descriptions\n * are the neutral agent-schema phrasing; an app that curates a longer\n * description for a block (e.g. plan's hand-drawn Mermaid, plan's detailed file\n * tree) passes an override rather than re-authoring the spec.\n */\nexport const libraryBlockConfigs: BlockSpec<any>[] = [\n defineBlock<ChecklistData>({\n type: \"checklist\",\n schema: checklistSchema,\n mdx: checklistMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n notionCompatible: true,\n label: \"Checklist\",\n description:\n \"A list of toggleable items, each with a label and an optional note.\",\n }),\n defineBlock<TableData>({\n type: \"table\",\n schema: tableSchema,\n mdx: tableMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n notionCompatible: true,\n label: \"Table\",\n description:\n \"A simple grid with header columns and string rows for comparisons, parameters, or structured lists.\",\n }),\n defineBlock<CodeTabsData>({\n type: \"code-tabs\",\n schema: codeTabsSchema,\n mdx: codeTabsMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"Code tabs\",\n description:\n \"A vertical file tab rail of syntax-highlighted code snippets, one tab per file with an optional language and caption.\",\n }),\n defineBlock<HtmlBlockData>({\n type: \"custom-html\",\n schema: htmlSchema,\n mdx: htmlMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"HTML / Tailwind\",\n description:\n \"An author-supplied HTML (with optional CSS) fragment rendered in a sandboxed iframe, with inline source editing.\",\n }),\n defineBlock<TabsData>({\n type: \"tabs\",\n schema: tabsSchema,\n mdx: tabsMdx,\n Read: ServerReadStub,\n placement: [\"block\", \"inline\"],\n label: \"Tabs\",\n description:\n \"A horizontal pill-tab container; each tab holds its own list of blocks.\",\n }),\n defineBlock<MermaidData>({\n type: \"mermaid\",\n schema: mermaidSchema,\n mdx: mermaidMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"Diagram (Mermaid)\",\n description:\n \"A Mermaid diagram (flowchart, sequence, etc.) defined as text and rendered as a diagram.\",\n }),\n defineBlock<ApiEndpointData>({\n type: \"api-endpoint\",\n schema: apiEndpointSchema,\n mdx: apiEndpointMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"API endpoint\",\n description:\n \"A Swagger-style API endpoint reference: a colored method pill + path, collapsed by default, expanding to params, request body, and per-status response examples.\",\n }),\n defineBlock<OpenApiSpecData>({\n type: \"openapi-spec\",\n schema: openApiSpecSchema,\n mdx: openApiSpecMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"OpenAPI spec\",\n description:\n \"A whole-document Redoc / Swagger-UI-style API reference rendered from a complete OpenAPI 3 / Swagger 2 spec (JSON).\",\n }),\n defineBlock<DataModelData>({\n type: \"data-model\",\n schema: dataModelSchema,\n mdx: dataModelMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"Data model\",\n description:\n \"An ERD / dbdiagram-style data model: entity cards with typed fields (PK/FK/nullable flags) and interactive foreign-key relations.\",\n }),\n defineBlock<DiffData>({\n type: \"diff\",\n schema: diffSchema,\n mdx: diffMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"Diff\",\n description:\n \"A GitHub-style before/after line diff for a file, with unified or split view and added/removed line highlighting.\",\n }),\n defineBlock<FileTreeData>({\n type: \"file-tree\",\n schema: fileTreeSchema,\n mdx: fileTreeMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"File tree\",\n description:\n \"A VS Code / GitHub-explorer file and change tree with per-file change badges, notes, and code snippets.\",\n }),\n defineBlock<JsonExplorerData>({\n type: \"json-explorer\",\n schema: jsonExplorerSchema,\n mdx: jsonExplorerMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"JSON explorer\",\n description:\n \"A collapsible browser-devtools / Postman-style JSON tree with type-colored values and expand/collapse.\",\n }),\n defineBlock<AnnotatedCodeData>({\n type: \"annotated-code\",\n schema: annotatedCodeSchema,\n mdx: annotatedCodeMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"Annotated code\",\n description:\n \"A line-numbered code walkthrough whose line ranges carry anchored explanatory notes.\",\n }),\n];\n\n/**\n * Per-block overrides for {@link registerLibraryBlockConfigs}, keyed by canonical\n * `type`. Servers tweak only the agent-facing fields that legitimately differ:\n * content re-types `table` → `table-block`; plan curates a longer Mermaid and\n * file-tree description. The `schema` / `mdx` config always stays shared.\n */\nexport type LibraryBlockConfigOverrides = Record<\n string,\n Partial<\n Pick<BlockSpec<any>, \"type\" | \"label\" | \"description\" | \"notionCompatible\">\n >\n>;\n\n/**\n * Register the React-free standard-library config stubs into a server / shared\n * {@link BlockRegistry}. Both `plan-block-registry.ts` and `nfm-registry.ts` call\n * this, then register only their app-specific block configs (plan adds callout /\n * diagram / wireframe / question-form) on top — so the shared library lives in\n * exactly one place across browser AND server registries.\n */\nexport function registerLibraryBlockConfigs(\n registry: BlockRegistry,\n options: { overrides?: LibraryBlockConfigOverrides } = {},\n): void {\n const overrides = options.overrides ?? {};\n const specs = libraryBlockConfigs.map((spec) => {\n const override = overrides[spec.type];\n return override ? ({ ...spec, ...override } as BlockSpec<any>) : spec;\n });\n registerBlocks(registry, specs);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"server-specs.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/server-specs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAsB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,CAAC;IACF,WAAW,CAAmB;QAC5B,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE,kBAAkB;QAC1B,GAAG,EAAE,eAAe;QACpB,IAAI,EAAE,cAAc;QACpB,SAAS,EAAE,CAAC,OAAO,CAAC;QACpB,KAAK,EAAE,eAAe;QACtB,WAAW,EACT,wGAAwG;KAC3G,CAAC;IACF,WAAW,CAAoB;QAC7B,IAAI,EAAE,gBAAgB;QACtB,MAAM,EAAE,mBAAmB;QAC3B,GAAG,EAAE,gBAAgB;QACrB,IAAI,EAAE,cAAc;QACpB,SAAS,EAAE,CAAC,OAAO,CAAC;QACpB,KAAK,EAAE,gBAAgB;QACvB,WAAW,EACT,sFAAsF;KACzF,CAAC;CACH,CAAC;AAeF;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAuB,EACvB,UAAuD,EAAE;IAEzD,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;IAC1C,MAAM,KAAK,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC7C,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtC,OAAO,QAAQ,CAAC,CAAC,CAAE,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAqB,CAAC,CAAC,CAAC,IAAI,CAAC;IACxE,CAAC,CAAC,CAAC;IACH,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import { defineBlock, type BlockSpec } from \"../types.js\";\nimport { registerBlocks, type BlockRegistry } from \"../registry.js\";\n\n// React-free schema + MDX config for the standard library. The matching React\n// `Read`/`Edit` live in the full client entry; the server path only ever touches\n// `spec.schema` / `spec.mdx`, so these configs register with a render-only stub.\nimport {\n checklistSchema,\n checklistMdx,\n type ChecklistData,\n} from \"./checklist.config.js\";\nimport { tableSchema, tableMdx, type TableData } from \"./table.config.js\";\nimport {\n codeTabsSchema,\n codeTabsMdx,\n type CodeTabsData,\n} from \"./code-tabs.config.js\";\nimport { htmlSchema, htmlMdx, type HtmlBlockData } from \"./html.config.js\";\nimport { tabsSchema, tabsMdx, type TabsData } from \"./tabs.config.js\";\nimport {\n columnsSchema,\n columnsMdx,\n type ColumnsData,\n} from \"./columns.config.js\";\nimport {\n mermaidSchema,\n mermaidMdx,\n type MermaidData,\n} from \"./mermaid.config.js\";\nimport {\n apiEndpointSchema,\n apiEndpointMdx,\n type ApiEndpointData,\n} from \"./api-endpoint.config.js\";\nimport {\n openApiSpecSchema,\n openApiSpecMdx,\n type OpenApiSpecData,\n} from \"./openapi-spec.config.js\";\nimport {\n dataModelSchema,\n dataModelMdx,\n type DataModelData,\n} from \"./data-model.config.js\";\nimport { diffSchema, diffMdx, type DiffData } from \"./diff.config.js\";\nimport {\n fileTreeSchema,\n fileTreeMdx,\n type FileTreeData,\n} from \"./file-tree.config.js\";\nimport {\n jsonExplorerSchema,\n jsonExplorerMdx,\n type JsonExplorerData,\n} from \"./json-explorer.config.js\";\nimport {\n annotatedCodeSchema,\n annotatedCodeMdx,\n type AnnotatedCodeData,\n} from \"./annotated-code.config.js\";\n\n/** Render-only stub for server / agent registries (never invoked off-browser). */\nconst ServerReadStub = () => null;\n\n/**\n * Canonical React-free specs for the standard library, used by BOTH apps' server\n * / shared registries (`plan-block-registry.ts`, `nfm-registry.ts`). Each carries\n * only the parts the server path touches — `schema` + `mdx` + metadata for the\n * agent schema export — with a render-only `Read` stub. The full client specs\n * (with real React `Read`/`Edit`) live in `./specs.tsx`; both share the identical\n * `schema`/`mdx` config so inline source can never drift from what renders.\n *\n * `table` keeps the core default `type` here; content's server registry renames\n * it to `table-block` via {@link LibraryBlockConfigOverrides}. The descriptions\n * are the neutral agent-schema phrasing; an app that curates a longer\n * description for a block (e.g. plan's hand-drawn Mermaid, plan's detailed file\n * tree) passes an override rather than re-authoring the spec.\n */\nexport const libraryBlockConfigs: BlockSpec<any>[] = [\n defineBlock<ChecklistData>({\n type: \"checklist\",\n schema: checklistSchema,\n mdx: checklistMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n notionCompatible: true,\n label: \"Checklist\",\n description:\n \"A list of toggleable items, each with a label and an optional note.\",\n }),\n defineBlock<TableData>({\n type: \"table\",\n schema: tableSchema,\n mdx: tableMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n notionCompatible: true,\n label: \"Table\",\n description:\n \"A simple grid with header columns and string rows for comparisons, parameters, or structured lists.\",\n }),\n defineBlock<CodeTabsData>({\n type: \"code-tabs\",\n schema: codeTabsSchema,\n mdx: codeTabsMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"Code tabs\",\n description:\n \"A vertical file tab rail of syntax-highlighted code snippets, one tab per file with an optional language and caption.\",\n }),\n defineBlock<HtmlBlockData>({\n type: \"custom-html\",\n schema: htmlSchema,\n mdx: htmlMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"HTML / Tailwind\",\n description:\n \"An author-supplied HTML (with optional CSS) fragment rendered in a sandboxed iframe, with inline source editing.\",\n }),\n defineBlock<TabsData>({\n type: \"tabs\",\n schema: tabsSchema,\n mdx: tabsMdx,\n Read: ServerReadStub,\n placement: [\"block\", \"inline\"],\n label: \"Tabs\",\n description:\n \"A top or side tab container; each tab holds its own list of blocks.\",\n }),\n defineBlock<ColumnsData>({\n type: \"columns\",\n schema: columnsSchema,\n mdx: columnsMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"Columns\",\n description:\n \"A multi-column side-by-side layout container; each column holds its own list of blocks. Ideal for before/after or current/target comparisons.\",\n }),\n defineBlock<MermaidData>({\n type: \"mermaid\",\n schema: mermaidSchema,\n mdx: mermaidMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"Diagram (Mermaid)\",\n description:\n \"A Mermaid diagram (flowchart, sequence, etc.) defined as text and rendered as a diagram.\",\n }),\n defineBlock<ApiEndpointData>({\n type: \"api-endpoint\",\n schema: apiEndpointSchema,\n mdx: apiEndpointMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"API endpoint\",\n description:\n \"A Swagger-style API endpoint reference: a colored method pill + path, collapsed by default, expanding to params, request body, and per-status response examples.\",\n }),\n defineBlock<OpenApiSpecData>({\n type: \"openapi-spec\",\n schema: openApiSpecSchema,\n mdx: openApiSpecMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"OpenAPI spec\",\n description:\n \"A whole-document API specification / Redoc / Swagger-UI-style API reference rendered from a complete OpenAPI 3 / Swagger 2 spec (JSON).\",\n }),\n defineBlock<DataModelData>({\n type: \"data-model\",\n schema: dataModelSchema,\n mdx: dataModelMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"Data model\",\n description:\n \"A schema modeling / ERD / dbdiagram-style data model: entity cards with typed fields (PK/FK/nullable flags) and interactive foreign-key relations.\",\n }),\n defineBlock<DiffData>({\n type: \"diff\",\n schema: diffSchema,\n mdx: diffMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"Diff\",\n description:\n \"A GitHub-style before/after line diff for a file, with unified or split view and added/removed line highlighting.\",\n }),\n defineBlock<FileTreeData>({\n type: \"file-tree\",\n schema: fileTreeSchema,\n mdx: fileTreeMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"File tree\",\n description:\n \"A VS Code / GitHub-explorer file and change tree with per-file change badges, notes, and code snippets.\",\n }),\n defineBlock<JsonExplorerData>({\n type: \"json-explorer\",\n schema: jsonExplorerSchema,\n mdx: jsonExplorerMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"JSON explorer\",\n description:\n \"A collapsible browser-devtools / Postman-style JSON tree with type-colored values and expand/collapse.\",\n }),\n defineBlock<AnnotatedCodeData>({\n type: \"annotated-code\",\n schema: annotatedCodeSchema,\n mdx: annotatedCodeMdx,\n Read: ServerReadStub,\n placement: [\"block\"],\n label: \"Annotated code\",\n description:\n \"A line-numbered code walkthrough whose line ranges carry anchored explanatory notes.\",\n }),\n];\n\n/**\n * Per-block overrides for {@link registerLibraryBlockConfigs}, keyed by canonical\n * `type`. Servers tweak only the agent-facing fields that legitimately differ:\n * content re-types `table` → `table-block`; plan curates a longer Mermaid and\n * file-tree description. The `schema` / `mdx` config always stays shared.\n */\nexport type LibraryBlockConfigOverrides = Record<\n string,\n Partial<\n Pick<BlockSpec<any>, \"type\" | \"label\" | \"description\" | \"notionCompatible\">\n >\n>;\n\n/**\n * Register the React-free standard-library config stubs into a server / shared\n * {@link BlockRegistry}. Both `plan-block-registry.ts` and `nfm-registry.ts` call\n * this, then register only their app-specific block configs (plan adds callout /\n * diagram / wireframe / question-form) on top — so the shared library lives in\n * exactly one place across browser AND server registries.\n */\nexport function registerLibraryBlockConfigs(\n registry: BlockRegistry,\n options: { overrides?: LibraryBlockConfigOverrides } = {},\n): void {\n const overrides = options.overrides ?? {};\n const specs = libraryBlockConfigs.map((spec) => {\n const override = overrides[spec.type];\n return override ? ({ ...spec, ...override } as BlockSpec<any>) : spec;\n });\n registerBlocks(registry, specs);\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type BlockSpec } from "../types.js";
|
|
2
2
|
import { type BlockRegistry } from "../registry.js";
|
|
3
3
|
/**
|
|
4
|
-
* The full standard library spec set, in registration order: the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* registries register — adding a
|
|
4
|
+
* The full standard library spec set, in registration order: the fully pre-built
|
|
5
|
+
* specs (checklist, table, code-tabs, html, tabs, columns) followed by the eight
|
|
6
|
+
* dev-doc specs. This is the single list both the plan and content browser
|
|
7
|
+
* registries register — adding a library block here lands in both apps.
|
|
8
8
|
*/
|
|
9
9
|
export declare const libraryBlockSpecs: BlockSpec<any>[];
|
|
10
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specs.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/specs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"specs.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/specs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AA2PpE;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,CAAC,GAAG,CAAC,EAQ7C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CACxC,MAAM,EACN,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,aAAa,GAAG,OAAO,CAAC,CAAC,CAC1E,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,aAAa,EACvB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,qBAAqB,CAAA;CAAO,GAClD,IAAI,CAON"}
|
|
@@ -6,6 +6,7 @@ import { tableBlock } from "./table.js";
|
|
|
6
6
|
import { codeTabsBlock } from "./code-tabs.js";
|
|
7
7
|
import { htmlBlock } from "./html.js";
|
|
8
8
|
import { tabsBlock } from "./tabs.js";
|
|
9
|
+
import { columnsBlock } from "./columns.js";
|
|
9
10
|
// Dev-doc blocks: React-free schema + MDX config paired with the shared React
|
|
10
11
|
// Read/Edit renderers. Composed into full specs below with canonical metadata.
|
|
11
12
|
import { mermaidSchema, mermaidMdx, } from "./mermaid.config.js";
|
|
@@ -20,21 +21,22 @@ import { diffSchema, diffMdx } from "./diff.config.js";
|
|
|
20
21
|
import { DiffRead, DiffEdit } from "./DiffBlock.js";
|
|
21
22
|
import { fileTreeSchema, fileTreeMdx, } from "./file-tree.config.js";
|
|
22
23
|
import { FileTreeRead, FileTreeEdit } from "./FileTreeBlock.js";
|
|
23
|
-
import { jsonExplorerSchema, jsonExplorerMdx, } from "./json-explorer.config.js";
|
|
24
|
+
import { jsonExplorerSchema, jsonExplorerMdx, JSON_EXPLORER_DEFAULT_COLLAPSED_DEPTH, } from "./json-explorer.config.js";
|
|
24
25
|
import { JsonExplorerRead, JsonExplorerEdit } from "./JsonExplorerBlock.js";
|
|
25
26
|
import { annotatedCodeSchema, annotatedCodeMdx, } from "./annotated-code.config.js";
|
|
26
27
|
import { AnnotatedCodeRead, AnnotatedCodeEdit } from "./AnnotatedCodeBlock.js";
|
|
27
28
|
/**
|
|
28
29
|
* Canonical specs for the standard library's dev-doc blocks (Mermaid, API
|
|
29
|
-
* endpoint, OpenAPI spec, data model, diff, file tree, JSON explorer,
|
|
30
|
-
* code).
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
30
|
+
* endpoint, OpenAPI spec, data model, diff, file tree, JSON explorer,
|
|
31
|
+
* annotated code).
|
|
32
|
+
* Each pairs the shared React-free schema/MDX config
|
|
33
|
+
* with the shared React `Read`/`Edit` renderers and the canonical
|
|
34
|
+
* label/description/editSurface/empty metadata. Apps that need a slightly
|
|
35
|
+
* different label/description/empty for a block pass an override to
|
|
36
|
+
* {@link registerLibraryBlocks} rather than re-authoring the whole spec.
|
|
35
37
|
*
|
|
36
|
-
* The
|
|
37
|
-
* tabs) already bundle their metadata in their own modules, so they are appended
|
|
38
|
+
* The six fully pre-built standard specs (checklist, table, code-tabs, html,
|
|
39
|
+
* tabs, columns) already bundle their metadata in their own modules, so they are appended
|
|
38
40
|
* by {@link libraryBlockSpecs} rather than re-declared here.
|
|
39
41
|
*/
|
|
40
42
|
// Typed `BlockSpec<any>[]` (not `BlockSpec<unknown>[]`) so the per-block generic
|
|
@@ -76,7 +78,7 @@ const devDocBlockSpecs = [
|
|
|
76
78
|
placement: ["block"],
|
|
77
79
|
editSurface: "panel",
|
|
78
80
|
label: "OpenAPI spec",
|
|
79
|
-
description: "A whole-document Redoc / Swagger-UI-style API reference rendered from a complete OpenAPI 3 / Swagger 2 spec (JSON): operations grouped by tag, each a collapsible row expanding to params, request body, and per-status responses, with $ref models resolved.",
|
|
81
|
+
description: "A whole-document API specification / Redoc / Swagger-UI-style API reference rendered from a complete OpenAPI 3 / Swagger 2 spec (JSON): operations grouped by tag, each a collapsible row expanding to params, request body, and per-status responses, with $ref models resolved.",
|
|
80
82
|
empty: () => ({
|
|
81
83
|
spec: JSON.stringify({
|
|
82
84
|
openapi: "3.0.0",
|
|
@@ -103,7 +105,7 @@ const devDocBlockSpecs = [
|
|
|
103
105
|
placement: ["block"],
|
|
104
106
|
editSurface: "panel",
|
|
105
107
|
label: "Data model",
|
|
106
|
-
description: "
|
|
108
|
+
description: "A schema modeling / ERD / dbdiagram-style data model: entity cards with typed fields (PK/FK/nullable flags) and interactive foreign-key relations.",
|
|
107
109
|
empty: () => ({
|
|
108
110
|
entities: [
|
|
109
111
|
{
|
|
@@ -171,6 +173,7 @@ const devDocBlockSpecs = [
|
|
|
171
173
|
tags: ["alpha", "beta"],
|
|
172
174
|
meta: { count: 2, owner: null },
|
|
173
175
|
}, null, 2),
|
|
176
|
+
collapsedDepth: JSON_EXPLORER_DEFAULT_COLLAPSED_DEPTH,
|
|
174
177
|
}),
|
|
175
178
|
}),
|
|
176
179
|
defineBlock({
|
|
@@ -182,8 +185,9 @@ const devDocBlockSpecs = [
|
|
|
182
185
|
placement: ["block"],
|
|
183
186
|
editSurface: "panel",
|
|
184
187
|
label: "Annotated code",
|
|
185
|
-
description: "A line-numbered code walkthrough whose line ranges carry anchored explanatory notes (Stripe-docs / Sourcegraph
|
|
188
|
+
description: "A line-numbered code walkthrough whose line ranges carry anchored explanatory notes (Stripe-docs / Sourcegraph explain-this-code style).",
|
|
186
189
|
empty: () => ({
|
|
190
|
+
filename: "src/server/auth.ts",
|
|
187
191
|
language: "ts",
|
|
188
192
|
code: "export function resolveAuth(provider: string) {\n const cfg = providers[provider];\n return cfg.token;\n}",
|
|
189
193
|
annotations: [
|
|
@@ -197,10 +201,10 @@ const devDocBlockSpecs = [
|
|
|
197
201
|
}),
|
|
198
202
|
];
|
|
199
203
|
/**
|
|
200
|
-
* The full standard library spec set, in registration order: the
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* registries register — adding a
|
|
204
|
+
* The full standard library spec set, in registration order: the fully pre-built
|
|
205
|
+
* specs (checklist, table, code-tabs, html, tabs, columns) followed by the eight
|
|
206
|
+
* dev-doc specs. This is the single list both the plan and content browser
|
|
207
|
+
* registries register — adding a library block here lands in both apps.
|
|
204
208
|
*/
|
|
205
209
|
export const libraryBlockSpecs = [
|
|
206
210
|
checklistBlock,
|
|
@@ -208,6 +212,7 @@ export const libraryBlockSpecs = [
|
|
|
208
212
|
codeTabsBlock,
|
|
209
213
|
htmlBlock,
|
|
210
214
|
tabsBlock,
|
|
215
|
+
columnsBlock,
|
|
211
216
|
...devDocBlockSpecs,
|
|
212
217
|
];
|
|
213
218
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specs.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/specs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAsB,MAAM,gBAAgB,CAAC;AAEpE,iFAAiF;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,8EAA8E;AAC9E,+EAA+E;AAC/E,OAAO,EACL,aAAa,EACb,UAAU,GAEX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW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BACX;oBACE,KAAK,EAAE,GAAG;oBACV,KAAK,EAAE,QAAQ;oBACf,IAAI,EAAE,sCAAsC;iBAC7C;aACF;SACF,CAAC;KACH,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAqB;IACjD,cAAc;IACd,UAAU;IACV,aAAa;IACb,SAAS;IACT,SAAS;IACT,GAAG,gBAAgB;CACpB,CAAC;AAcF;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAuB,EACvB,UAAiD,EAAE;IAEnD,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;IAC1C,MAAM,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC3C,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtC,OAAO,QAAQ,CAAC,CAAC,CAAE,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAqB,CAAC,CAAC,CAAC,IAAI,CAAC;IACxE,CAAC,CAAC,CAAC;IACH,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import { defineBlock, type BlockSpec } from \"../types.js\";\nimport { registerBlocks, type BlockRegistry } from \"../registry.js\";\n\n// Pre-built standard library specs (schema + mdx + React Read/Edit all bundled).\nimport { checklistBlock } from \"./checklist.js\";\nimport { tableBlock } from \"./table.js\";\nimport { codeTabsBlock } from \"./code-tabs.js\";\nimport { htmlBlock } from \"./html.js\";\nimport { tabsBlock } from \"./tabs.js\";\n\n// Dev-doc blocks: React-free schema + MDX config paired with the shared React\n// Read/Edit renderers. Composed into full specs below with canonical metadata.\nimport {\n mermaidSchema,\n mermaidMdx,\n type MermaidData,\n} from \"./mermaid.config.js\";\nimport { MermaidRead, MermaidEdit } from \"./MermaidBlock.js\";\nimport {\n apiEndpointSchema,\n apiEndpointMdx,\n type ApiEndpointData,\n} from \"./api-endpoint.config.js\";\nimport { ApiEndpointRead, ApiEndpointEdit } from \"./ApiEndpointBlock.js\";\nimport {\n openApiSpecSchema,\n openApiSpecMdx,\n type OpenApiSpecData,\n} from \"./openapi-spec.config.js\";\nimport { OpenApiSpecRead, OpenApiSpecEdit } from \"./OpenApiSpecBlock.js\";\nimport {\n dataModelSchema,\n dataModelMdx,\n type DataModelData,\n} from \"./data-model.config.js\";\nimport { DataModelRead, DataModelEdit } from \"./DataModelBlock.js\";\nimport { diffSchema, diffMdx, type DiffData } from \"./diff.config.js\";\nimport { DiffRead, DiffEdit } from \"./DiffBlock.js\";\nimport {\n fileTreeSchema,\n fileTreeMdx,\n type FileTreeData,\n} from \"./file-tree.config.js\";\nimport { FileTreeRead, FileTreeEdit } from \"./FileTreeBlock.js\";\nimport {\n jsonExplorerSchema,\n jsonExplorerMdx,\n type JsonExplorerData,\n} from \"./json-explorer.config.js\";\nimport { JsonExplorerRead, JsonExplorerEdit } from \"./JsonExplorerBlock.js\";\nimport {\n annotatedCodeSchema,\n annotatedCodeMdx,\n type AnnotatedCodeData,\n} from \"./annotated-code.config.js\";\nimport { AnnotatedCodeRead, AnnotatedCodeEdit } from \"./AnnotatedCodeBlock.js\";\n\n/**\n * Canonical specs for the standard library's dev-doc blocks (Mermaid, API\n * endpoint, OpenAPI spec, data model, diff, file tree, JSON explorer, annotated\n * code). Each pairs the shared React-free schema/MDX config with the shared\n * React `Read`/`Edit` renderers and the canonical label/description/editSurface/\n * empty metadata. Apps that need a slightly different label/description/empty for\n * a block pass an override to {@link registerLibraryBlocks} rather than\n * re-authoring the whole spec.\n *\n * The five fully pre-built standard specs (checklist, table, code-tabs, html,\n * tabs) already bundle their metadata in their own modules, so they are appended\n * by {@link libraryBlockSpecs} rather than re-declared here.\n */\n// Typed `BlockSpec<any>[]` (not `BlockSpec<unknown>[]`) so the per-block generic\n// data types coexist in one array — mirroring `registerBlocks`' own signature,\n// where `childrenField: keyof TData` would otherwise collapse to `never`.\nconst devDocBlockSpecs: BlockSpec<any>[] = [\n defineBlock<MermaidData>({\n type: \"mermaid\",\n schema: mermaidSchema,\n mdx: mermaidMdx,\n Read: MermaidRead,\n Edit: MermaidEdit,\n placement: [\"block\"],\n editSurface: \"panel\",\n label: \"Diagram (Mermaid)\",\n description:\n \"A Mermaid diagram (flowchart, sequence, etc.) defined as text and rendered as a diagram.\",\n empty: () => ({\n source:\n \"flowchart TD\\n A[Start] --> B{Decision}\\n B -->|Yes| C[Do it]\\n B -->|No| D[Skip]\",\n }),\n }),\n defineBlock<ApiEndpointData>({\n type: \"api-endpoint\",\n schema: apiEndpointSchema,\n mdx: apiEndpointMdx,\n Read: ApiEndpointRead,\n Edit: ApiEndpointEdit,\n placement: [\"block\"],\n editSurface: \"panel\",\n label: \"API endpoint\",\n description:\n \"A Swagger-style API endpoint reference: a colored method pill + path, collapsed by default, expanding to params, request body, and per-status response examples.\",\n empty: () => ({ method: \"GET\", path: \"/api/resource\" }),\n }),\n defineBlock<OpenApiSpecData>({\n type: \"openapi-spec\",\n schema: openApiSpecSchema,\n mdx: openApiSpecMdx,\n Read: OpenApiSpecRead,\n Edit: OpenApiSpecEdit,\n placement: [\"block\"],\n editSurface: \"panel\",\n label: \"OpenAPI spec\",\n description:\n \"A whole-document Redoc / Swagger-UI-style API reference rendered from a complete OpenAPI 3 / Swagger 2 spec (JSON): operations grouped by tag, each a collapsible row expanding to params, request body, and per-status responses, with $ref models resolved.\",\n empty: () => ({\n spec: JSON.stringify(\n {\n openapi: \"3.0.0\",\n info: { title: \"Example API\", version: \"1.0.0\" },\n tags: [{ name: \"widgets\", description: \"Manage widgets\" }],\n paths: {\n \"/widgets\": {\n get: {\n tags: [\"widgets\"],\n summary: \"List widgets\",\n responses: { \"200\": { description: \"OK\" } },\n },\n },\n },\n },\n null,\n 2,\n ),\n }),\n }),\n defineBlock<DataModelData>({\n type: \"data-model\",\n schema: dataModelSchema,\n mdx: dataModelMdx,\n Read: DataModelRead,\n Edit: DataModelEdit,\n placement: [\"block\"],\n editSurface: \"panel\",\n label: \"Data model\",\n description:\n \"An ERD / dbdiagram-style data model: entity cards with typed fields (PK/FK/nullable flags) and interactive foreign-key relations.\",\n empty: () => ({\n entities: [\n {\n id: \"e_user\",\n name: \"User\",\n fields: [\n { name: \"id\", type: \"uuid\", pk: true },\n { name: \"email\", type: \"text\" },\n ],\n },\n ],\n }),\n }),\n defineBlock<DiffData>({\n type: \"diff\",\n schema: diffSchema,\n mdx: diffMdx,\n Read: DiffRead,\n Edit: DiffEdit,\n placement: [\"block\"],\n editSurface: \"panel\",\n label: \"Diff\",\n description:\n \"A GitHub-style before/after line diff for a file, with unified or split (side-by-side) view, added/removed line highlighting, and collapsible unchanged runs.\",\n empty: () => ({\n before: \"function add(a, b) {\\n return a + b;\\n}\",\n after: \"function add(a: number, b: number): number {\\n return a + b;\\n}\",\n language: \"ts\",\n }),\n }),\n defineBlock<FileTreeData>({\n type: \"file-tree\",\n schema: fileTreeSchema,\n mdx: fileTreeMdx,\n Read: FileTreeRead,\n Edit: FileTreeEdit,\n placement: [\"block\"],\n editSurface: \"panel\",\n label: \"File tree\",\n description:\n \"A VS Code / GitHub-explorer file and change tree derived from slash-delimited paths, with per-file change badges (added/modified/removed/renamed), notes, and code snippets.\",\n empty: () => ({\n entries: [\n {\n path: \"src/index.ts\",\n change: \"modified\",\n note: \"Wire the new route here.\",\n },\n { path: \"src/routes/git.ts\", change: \"added\" },\n ],\n }),\n }),\n defineBlock<JsonExplorerData>({\n type: \"json-explorer\",\n schema: jsonExplorerSchema,\n mdx: jsonExplorerMdx,\n Read: JsonExplorerRead,\n Edit: JsonExplorerEdit,\n placement: [\"block\"],\n editSurface: \"panel\",\n label: \"JSON explorer\",\n description:\n \"A collapsible browser-devtools / Postman-style JSON tree with type-colored values and expand/collapse.\",\n empty: () => ({\n json: JSON.stringify(\n {\n id: \"abc123\",\n active: true,\n tags: [\"alpha\", \"beta\"],\n meta: { count: 2, owner: null },\n },\n null,\n 2,\n ),\n }),\n }),\n defineBlock<AnnotatedCodeData>({\n type: \"annotated-code\",\n schema: annotatedCodeSchema,\n mdx: annotatedCodeMdx,\n Read: AnnotatedCodeRead,\n Edit: AnnotatedCodeEdit,\n placement: [\"block\"],\n editSurface: \"panel\",\n label: \"Annotated code\",\n description:\n \"A line-numbered code walkthrough whose line ranges carry anchored explanatory notes (Stripe-docs / Sourcegraph 'explain this code' style).\",\n empty: () => ({\n language: \"ts\",\n code: \"export function resolveAuth(provider: string) {\\n const cfg = providers[provider];\\n return cfg.token;\\n}\",\n annotations: [\n {\n lines: \"2\",\n label: \"Lookup\",\n note: \"Resolves the provider config by key.\",\n },\n ],\n }),\n }),\n];\n\n/**\n * The full standard library spec set, in registration order: the five fully\n * pre-built specs (checklist, table, code-tabs, html, tabs) followed by the\n * eight dev-doc specs. This is the single list both the plan and content browser\n * registries register — adding a 14th library block here lands in both apps.\n */\nexport const libraryBlockSpecs: BlockSpec<any>[] = [\n checklistBlock,\n tableBlock,\n codeTabsBlock,\n htmlBlock,\n tabsBlock,\n ...devDocBlockSpecs,\n];\n\n/**\n * Per-block metadata overrides for {@link registerLibraryBlocks}, keyed by the\n * canonical block `type`. Lets an app tweak the few fields that legitimately\n * differ (a `type` rename, a tweaked `description` or `empty` seed) without\n * re-authoring the spec. Anything omitted keeps the canonical value, so the\n * schema / MDX config and the React `Read`/`Edit` renderers always stay shared.\n */\nexport type LibraryBlockOverrides = Record<\n string,\n Partial<Pick<BlockSpec<any>, \"type\" | \"label\" | \"description\" | \"empty\">>\n>;\n\n/**\n * Register the standard library block specs into a {@link BlockRegistry}. Both\n * the plan and content browser registries call this, then register only their\n * own app-specific blocks on top — so the shared library lives in exactly one\n * place. Pass `overrides` (keyed by canonical `type`) for the small per-app\n * differences (content re-types `table` → `table-block`; each app phrases the\n * Mermaid description and seeds the OpenAPI example a little differently).\n */\nexport function registerLibraryBlocks(\n registry: BlockRegistry,\n options: { overrides?: LibraryBlockOverrides } = {},\n): void {\n const overrides = options.overrides ?? {};\n const specs = libraryBlockSpecs.map((spec) => {\n const override = overrides[spec.type];\n return override ? ({ ...spec, ...override } as BlockSpec<any>) : spec;\n });\n registerBlocks(registry, specs);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"specs.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/specs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAsB,MAAM,gBAAgB,CAAC;AAEpE,iFAAiF;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,8EAA8E;AAC9E,+EAA+E;AAC/E,OAAO,EACL,aAAa,EACb,UAAU,GAEX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EACL,iBAAiB,EACjB,cAAc,GAEf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EACL,iBAAiB,EACjB,cAAc,GAEf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EACL,eAAe,EACf,YAAY,GAEb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAiB,MAAM,kBAAkB,CAAC;AACtE,OAA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IAC1C,MAAM,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC3C,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtC,OAAO,QAAQ,CAAC,CAAC,CAAE,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAqB,CAAC,CAAC,CAAC,IAAI,CAAC;IACxE,CAAC,CAAC,CAAC;IACH,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import { defineBlock, type BlockSpec } from \"../types.js\";\nimport { registerBlocks, type BlockRegistry } from \"../registry.js\";\n\n// Pre-built standard library specs (schema + mdx + React Read/Edit all bundled).\nimport { checklistBlock } from \"./checklist.js\";\nimport { tableBlock } from \"./table.js\";\nimport { codeTabsBlock } from \"./code-tabs.js\";\nimport { htmlBlock } from \"./html.js\";\nimport { tabsBlock } from \"./tabs.js\";\nimport { columnsBlock } from \"./columns.js\";\n\n// Dev-doc blocks: React-free schema + MDX config paired with the shared React\n// Read/Edit renderers. Composed into full specs below with canonical metadata.\nimport {\n mermaidSchema,\n mermaidMdx,\n type MermaidData,\n} from \"./mermaid.config.js\";\nimport { MermaidRead, MermaidEdit } from \"./MermaidBlock.js\";\nimport {\n apiEndpointSchema,\n apiEndpointMdx,\n type ApiEndpointData,\n} from \"./api-endpoint.config.js\";\nimport { ApiEndpointRead, ApiEndpointEdit } from \"./ApiEndpointBlock.js\";\nimport {\n openApiSpecSchema,\n openApiSpecMdx,\n type OpenApiSpecData,\n} from \"./openapi-spec.config.js\";\nimport { OpenApiSpecRead, OpenApiSpecEdit } from \"./OpenApiSpecBlock.js\";\nimport {\n dataModelSchema,\n dataModelMdx,\n type DataModelData,\n} from \"./data-model.config.js\";\nimport { DataModelRead, DataModelEdit } from \"./DataModelBlock.js\";\nimport { diffSchema, diffMdx, type DiffData } from \"./diff.config.js\";\nimport { DiffRead, DiffEdit } from \"./DiffBlock.js\";\nimport {\n fileTreeSchema,\n fileTreeMdx,\n type FileTreeData,\n} from \"./file-tree.config.js\";\nimport { FileTreeRead, FileTreeEdit } from \"./FileTreeBlock.js\";\nimport {\n jsonExplorerSchema,\n jsonExplorerMdx,\n JSON_EXPLORER_DEFAULT_COLLAPSED_DEPTH,\n type JsonExplorerData,\n} from \"./json-explorer.config.js\";\nimport { JsonExplorerRead, JsonExplorerEdit } from \"./JsonExplorerBlock.js\";\nimport {\n annotatedCodeSchema,\n annotatedCodeMdx,\n type AnnotatedCodeData,\n} from \"./annotated-code.config.js\";\nimport { AnnotatedCodeRead, AnnotatedCodeEdit } from \"./AnnotatedCodeBlock.js\";\n\n/**\n * Canonical specs for the standard library's dev-doc blocks (Mermaid, API\n * endpoint, OpenAPI spec, data model, diff, file tree, JSON explorer,\n * annotated code).\n * Each pairs the shared React-free schema/MDX config\n * with the shared React `Read`/`Edit` renderers and the canonical\n * label/description/editSurface/empty metadata. Apps that need a slightly\n * different label/description/empty for a block pass an override to\n * {@link registerLibraryBlocks} rather than re-authoring the whole spec.\n *\n * The six fully pre-built standard specs (checklist, table, code-tabs, html,\n * tabs, columns) already bundle their metadata in their own modules, so they are appended\n * by {@link libraryBlockSpecs} rather than re-declared here.\n */\n// Typed `BlockSpec<any>[]` (not `BlockSpec<unknown>[]`) so the per-block generic\n// data types coexist in one array — mirroring `registerBlocks`' own signature,\n// where `childrenField: keyof TData` would otherwise collapse to `never`.\nconst devDocBlockSpecs: BlockSpec<any>[] = [\n defineBlock<MermaidData>({\n type: \"mermaid\",\n schema: mermaidSchema,\n mdx: mermaidMdx,\n Read: MermaidRead,\n Edit: MermaidEdit,\n placement: [\"block\"],\n editSurface: \"panel\",\n label: \"Diagram (Mermaid)\",\n description:\n \"A Mermaid diagram (flowchart, sequence, etc.) defined as text and rendered as a diagram.\",\n empty: () => ({\n source:\n \"flowchart TD\\n A[Start] --> B{Decision}\\n B -->|Yes| C[Do it]\\n B -->|No| D[Skip]\",\n }),\n }),\n defineBlock<ApiEndpointData>({\n type: \"api-endpoint\",\n schema: apiEndpointSchema,\n mdx: apiEndpointMdx,\n Read: ApiEndpointRead,\n Edit: ApiEndpointEdit,\n placement: [\"block\"],\n editSurface: \"panel\",\n label: \"API endpoint\",\n description:\n \"A Swagger-style API endpoint reference: a colored method pill + path, collapsed by default, expanding to params, request body, and per-status response examples.\",\n empty: () => ({ method: \"GET\", path: \"/api/resource\" }),\n }),\n defineBlock<OpenApiSpecData>({\n type: \"openapi-spec\",\n schema: openApiSpecSchema,\n mdx: openApiSpecMdx,\n Read: OpenApiSpecRead,\n Edit: OpenApiSpecEdit,\n placement: [\"block\"],\n editSurface: \"panel\",\n label: \"OpenAPI spec\",\n description:\n \"A whole-document API specification / Redoc / Swagger-UI-style API reference rendered from a complete OpenAPI 3 / Swagger 2 spec (JSON): operations grouped by tag, each a collapsible row expanding to params, request body, and per-status responses, with $ref models resolved.\",\n empty: () => ({\n spec: JSON.stringify(\n {\n openapi: \"3.0.0\",\n info: { title: \"Example API\", version: \"1.0.0\" },\n tags: [{ name: \"widgets\", description: \"Manage widgets\" }],\n paths: {\n \"/widgets\": {\n get: {\n tags: [\"widgets\"],\n summary: \"List widgets\",\n responses: { \"200\": { description: \"OK\" } },\n },\n },\n },\n },\n null,\n 2,\n ),\n }),\n }),\n defineBlock<DataModelData>({\n type: \"data-model\",\n schema: dataModelSchema,\n mdx: dataModelMdx,\n Read: DataModelRead,\n Edit: DataModelEdit,\n placement: [\"block\"],\n editSurface: \"panel\",\n label: \"Data model\",\n description:\n \"A schema modeling / ERD / dbdiagram-style data model: entity cards with typed fields (PK/FK/nullable flags) and interactive foreign-key relations.\",\n empty: () => ({\n entities: [\n {\n id: \"e_user\",\n name: \"User\",\n fields: [\n { name: \"id\", type: \"uuid\", pk: true },\n { name: \"email\", type: \"text\" },\n ],\n },\n ],\n }),\n }),\n defineBlock<DiffData>({\n type: \"diff\",\n schema: diffSchema,\n mdx: diffMdx,\n Read: DiffRead,\n Edit: DiffEdit,\n placement: [\"block\"],\n editSurface: \"panel\",\n label: \"Diff\",\n description:\n \"A GitHub-style before/after line diff for a file, with unified or split (side-by-side) view, added/removed line highlighting, and collapsible unchanged runs.\",\n empty: () => ({\n before: \"function add(a, b) {\\n return a + b;\\n}\",\n after: \"function add(a: number, b: number): number {\\n return a + b;\\n}\",\n language: \"ts\",\n }),\n }),\n defineBlock<FileTreeData>({\n type: \"file-tree\",\n schema: fileTreeSchema,\n mdx: fileTreeMdx,\n Read: FileTreeRead,\n Edit: FileTreeEdit,\n placement: [\"block\"],\n editSurface: \"panel\",\n label: \"File tree\",\n description:\n \"A VS Code / GitHub-explorer file and change tree derived from slash-delimited paths, with per-file change badges (added/modified/removed/renamed), notes, and code snippets.\",\n empty: () => ({\n entries: [\n {\n path: \"src/index.ts\",\n change: \"modified\",\n note: \"Wire the new route here.\",\n },\n { path: \"src/routes/git.ts\", change: \"added\" },\n ],\n }),\n }),\n defineBlock<JsonExplorerData>({\n type: \"json-explorer\",\n schema: jsonExplorerSchema,\n mdx: jsonExplorerMdx,\n Read: JsonExplorerRead,\n Edit: JsonExplorerEdit,\n placement: [\"block\"],\n editSurface: \"panel\",\n label: \"JSON explorer\",\n description:\n \"A collapsible browser-devtools / Postman-style JSON tree with type-colored values and expand/collapse.\",\n empty: () => ({\n json: JSON.stringify(\n {\n id: \"abc123\",\n active: true,\n tags: [\"alpha\", \"beta\"],\n meta: { count: 2, owner: null },\n },\n null,\n 2,\n ),\n collapsedDepth: JSON_EXPLORER_DEFAULT_COLLAPSED_DEPTH,\n }),\n }),\n defineBlock<AnnotatedCodeData>({\n type: \"annotated-code\",\n schema: annotatedCodeSchema,\n mdx: annotatedCodeMdx,\n Read: AnnotatedCodeRead,\n Edit: AnnotatedCodeEdit,\n placement: [\"block\"],\n editSurface: \"panel\",\n label: \"Annotated code\",\n description:\n \"A line-numbered code walkthrough whose line ranges carry anchored explanatory notes (Stripe-docs / Sourcegraph explain-this-code style).\",\n empty: () => ({\n filename: \"src/server/auth.ts\",\n language: \"ts\",\n code: \"export function resolveAuth(provider: string) {\\n const cfg = providers[provider];\\n return cfg.token;\\n}\",\n annotations: [\n {\n lines: \"2\",\n label: \"Lookup\",\n note: \"Resolves the provider config by key.\",\n },\n ],\n }),\n }),\n];\n\n/**\n * The full standard library spec set, in registration order: the fully pre-built\n * specs (checklist, table, code-tabs, html, tabs, columns) followed by the eight\n * dev-doc specs. This is the single list both the plan and content browser\n * registries register — adding a library block here lands in both apps.\n */\nexport const libraryBlockSpecs: BlockSpec<any>[] = [\n checklistBlock,\n tableBlock,\n codeTabsBlock,\n htmlBlock,\n tabsBlock,\n columnsBlock,\n ...devDocBlockSpecs,\n];\n\n/**\n * Per-block metadata overrides for {@link registerLibraryBlocks}, keyed by the\n * canonical block `type`. Lets an app tweak the few fields that legitimately\n * differ (a `type` rename, a tweaked `description` or `empty` seed) without\n * re-authoring the spec. Anything omitted keeps the canonical value, so the\n * schema / MDX config and the React `Read`/`Edit` renderers always stay shared.\n */\nexport type LibraryBlockOverrides = Record<\n string,\n Partial<Pick<BlockSpec<any>, \"type\" | \"label\" | \"description\" | \"empty\">>\n>;\n\n/**\n * Register the standard library block specs into a {@link BlockRegistry}. Both\n * the plan and content browser registries call this, then register only their\n * own app-specific blocks on top — so the shared library lives in exactly one\n * place. Pass `overrides` (keyed by canonical `type`) for the small per-app\n * differences (content re-types `table` → `table-block`; each app phrases the\n * Mermaid description and seeds the OpenAPI example a little differently).\n */\nexport function registerLibraryBlocks(\n registry: BlockRegistry,\n options: { overrides?: LibraryBlockOverrides } = {},\n): void {\n const overrides = options.overrides ?? {};\n const specs = libraryBlockSpecs.map((spec) => {\n const override = overrides[spec.type];\n return override ? ({ ...spec, ...override } as BlockSpec<any>) : spec;\n });\n registerBlocks(registry, specs);\n}\n"]}
|
|
@@ -16,7 +16,10 @@ import type { BlockMdxConfig } from "../types.js";
|
|
|
16
16
|
export interface TableData {
|
|
17
17
|
columns: string[];
|
|
18
18
|
rows: string[][];
|
|
19
|
+
density?: TableDensity;
|
|
19
20
|
}
|
|
21
|
+
export declare const TABLE_DENSITIES: readonly ["compact", "normal", "relaxed"];
|
|
22
|
+
export type TableDensity = (typeof TABLE_DENSITIES)[number];
|
|
20
23
|
export declare const tableSchema: z.ZodType<TableData>;
|
|
21
24
|
/**
|
|
22
25
|
* MDX config: `columns` and `rows` are JSON attributes (no children) — exactly
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.config.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/table.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"table.config.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/table.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAED,eAAO,MAAM,eAAe,2CAA4C,CAAC;AACzE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5D,eAAO,MAAM,WAAW,EAIP,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAEtC;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,cAAc,CAAC,SAAS,CAa9C,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
export const TABLE_DENSITIES = ["compact", "normal", "relaxed"];
|
|
2
3
|
export const tableSchema = z.object({
|
|
3
4
|
columns: z.array(z.string()),
|
|
4
5
|
rows: z.array(z.array(z.string())),
|
|
6
|
+
density: z.enum(TABLE_DENSITIES).optional(),
|
|
5
7
|
});
|
|
6
8
|
/**
|
|
7
9
|
* MDX config: `columns` and `rows` are JSON attributes (no children) — exactly
|
|
@@ -13,10 +15,20 @@ export const tableSchema = z.object({
|
|
|
13
15
|
*/
|
|
14
16
|
export const tableMdx = {
|
|
15
17
|
tag: "Table",
|
|
16
|
-
toAttrs: (data) => ({
|
|
18
|
+
toAttrs: (data) => ({
|
|
19
|
+
columns: data.columns,
|
|
20
|
+
rows: data.rows,
|
|
21
|
+
density: data.density && data.density !== "normal" ? data.density : undefined,
|
|
22
|
+
}),
|
|
17
23
|
fromAttrs: (attrs) => ({
|
|
18
24
|
columns: attrs.array("columns") ?? [],
|
|
19
25
|
rows: attrs.array("rows") ?? [],
|
|
26
|
+
density: parseDensity(attrs.string("density")),
|
|
20
27
|
}),
|
|
21
28
|
};
|
|
29
|
+
function parseDensity(value) {
|
|
30
|
+
return value && TABLE_DENSITIES.includes(value)
|
|
31
|
+
? value
|
|
32
|
+
: undefined;
|
|
33
|
+
}
|
|
22
34
|
//# sourceMappingURL=table.config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.config.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/table.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"table.config.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/table.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAuBxB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,QAAQ,E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table` block: its data schema and MDX\n * round-trip config. Shared by the server MDX adapter (the plan\n * `plan-block-registry.ts` → `plan-mdx.ts`) and the client spec\n * (`table.tsx`). Keeping it React-free means a server module that imports it\n * never pulls React into the Nitro/SSR bundle.\n *\n * The schema MUST stay data-compatible with the legacy `table` branch of the\n * plan `planBlockSchema` (`{ columns: string[]; rows: string[][] }`), and the\n * MDX `tag` + attribute shape MUST match the legacy self-closing\n * `<Table … columns={…} rows={…} />` encoding (`plan-mdx.ts`\n * `serializeBlock`/`parseBlock`) so stored `.mdx` round-trips byte-compatibly.\n */\n\nexport interface TableData {\n columns: string[];\n rows: string[][];\n density?: TableDensity;\n}\n\nexport const TABLE_DENSITIES = [\"compact\", \"normal\", \"relaxed\"] as const;\nexport type TableDensity = (typeof TABLE_DENSITIES)[number];\n\nexport const tableSchema = z.object({\n columns: z.array(z.string()),\n rows: z.array(z.array(z.string())),\n density: z.enum(TABLE_DENSITIES).optional(),\n}) as unknown as z.ZodType<TableData>;\n\n/**\n * MDX config: `columns` and `rows` are JSON attributes (no children) — exactly\n * the legacy self-closing `<Table id title summary editable columns={…} rows={…} />`\n * form. The legacy serializer emits `columns` before `rows`; `toAttrs` returns\n * the keys in that exact insertion order because `serializeSpecBlock` preserves\n * `Object.entries` order. `fromAttrs` mirrors the legacy parser's `?? []`\n * defaults so partial/older nodes stay tolerant.\n */\nexport const tableMdx: BlockMdxConfig<TableData> = {\n tag: \"Table\",\n toAttrs: (data) => ({\n columns: data.columns,\n rows: data.rows,\n density:\n data.density && data.density !== \"normal\" ? data.density : undefined,\n }),\n fromAttrs: (attrs) => ({\n columns: attrs.array<string>(\"columns\") ?? [],\n rows: attrs.array<string[]>(\"rows\") ?? [],\n density: parseDensity(attrs.string(\"density\")),\n }),\n};\n\nfunction parseDensity(value: string | undefined): TableDensity | undefined {\n return value && TABLE_DENSITIES.includes(value as TableDensity)\n ? (value as TableDensity)\n : undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/table.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/table.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAGL,KAAK,SAAS,EAEf,MAAM,mBAAmB,CAAC;AAyY3B;;;;GAIG;AACH,eAAO,MAAM,UAAU,4CAuBrB,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLayoutEffect, useRef, } from "react";
|
|
2
3
|
import { IconColumnInsertRight, IconPlus, IconRowInsertBottom, IconTable, IconTrash, IconX, } from "@tabler/icons-react";
|
|
3
4
|
import { defineBlock } from "../types.js";
|
|
4
|
-
import { tableMdx, tableSchema } from "./table.config.js";
|
|
5
|
+
import { tableMdx, tableSchema, } from "./table.config.js";
|
|
5
6
|
/**
|
|
6
7
|
* Standard `table` block — a simple grid of header columns and string rows.
|
|
7
8
|
* STANDARD library block: lives in core (`@agent-native/core/blocks`) so any
|
|
@@ -20,12 +21,87 @@ import { tableMdx, tableSchema } from "./table.config.js";
|
|
|
20
21
|
* consuming app's CSS — core only emits the markup, exactly like the existing
|
|
21
22
|
* `CalloutBlock` read renderer.
|
|
22
23
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
const densityClasses = {
|
|
25
|
+
compact: {
|
|
26
|
+
header: "py-1.5",
|
|
27
|
+
cell: "py-2",
|
|
28
|
+
},
|
|
29
|
+
normal: {
|
|
30
|
+
header: "py-3",
|
|
31
|
+
cell: "py-4",
|
|
32
|
+
},
|
|
33
|
+
relaxed: {
|
|
34
|
+
header: "py-5",
|
|
35
|
+
cell: "py-6",
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
function resolveDensity(data) {
|
|
39
|
+
return data.density ?? "normal";
|
|
40
|
+
}
|
|
41
|
+
function TableBlockRead({ data, blockId, title, ctx, }) {
|
|
42
|
+
const density = resolveDensity(data);
|
|
43
|
+
const spacing = densityClasses[density];
|
|
44
|
+
return (_jsxs("section", { className: "plan-block overflow-x-auto", "data-block-id": blockId, children: [title && _jsx("div", { className: "plan-block-label", children: title }), _jsxs("table", { className: "w-full min-w-[640px] border-collapse text-left", children: [_jsx("thead", { children: _jsx("tr", { className: "border-b border-plan-line text-sm text-plan-muted", children: data.columns.map((column) => (_jsx("th", { className: `${spacing.header} pr-4 font-semibold`, children: renderTableMarkdown(ctx, column, tableHeaderMarkdownClass) }, column))) }) }), _jsx("tbody", { children: data.rows.map((row, index) => (_jsx("tr", { className: "border-b border-plan-line", children: row.map((cell, cellIndex) => (_jsx("td", { className: `${spacing.cell} pr-4 text-plan-muted`, children: renderTableMarkdown(ctx, cell, tableCellMarkdownClass) }, cellIndex))) }, index))) })] })] }));
|
|
45
|
+
}
|
|
46
|
+
const tableCellMarkdownClass = "an-table-cell-markdown mt-0 max-w-none text-plan-muted";
|
|
47
|
+
const tableHeaderMarkdownClass = `${tableCellMarkdownClass} an-table-cell-markdown--header font-semibold`;
|
|
48
|
+
const plainTextFieldBaseClass = "min-h-6 w-full whitespace-pre-wrap break-words rounded-sm border border-transparent bg-transparent px-0 leading-6 text-plan-muted outline-none focus:border-transparent focus:bg-transparent focus:px-0 focus:outline-none focus:ring-0 focus-visible:border-transparent focus-visible:bg-transparent focus-visible:px-0 focus-visible:outline-none focus-visible:ring-0 data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50";
|
|
49
|
+
const iconButtonBaseClass = "inline-flex size-7 items-center justify-center rounded-md border border-input bg-background/80 text-muted-foreground opacity-0 shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:opacity-100 disabled:cursor-not-allowed disabled:opacity-50";
|
|
50
|
+
const tableHoverIconButtonClass = `${iconButtonBaseClass} group-hover/table:opacity-100`;
|
|
51
|
+
const columnHoverIconButtonClass = `${iconButtonBaseClass} group-hover/column:opacity-100`;
|
|
52
|
+
const rowHoverIconButtonClass = `${iconButtonBaseClass} group-hover/row:opacity-100`;
|
|
53
|
+
const addButtonClass = "inline-flex items-center gap-1.5 rounded-md border border-input bg-transparent px-3 py-1.5 text-sm text-muted-foreground opacity-0 transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:opacity-100 group-hover/table:opacity-100 disabled:cursor-not-allowed disabled:opacity-50";
|
|
54
|
+
function renderTableMarkdown(ctx, value, className) {
|
|
55
|
+
return ctx.renderMarkdown?.(value, { className }) ?? value;
|
|
56
|
+
}
|
|
57
|
+
function TableMarkdownField({ ctx, value, onChange, editable, ariaLabel, className, }) {
|
|
58
|
+
const editor = ctx.renderMarkdownEditor?.({
|
|
59
|
+
value,
|
|
60
|
+
onChange,
|
|
61
|
+
editable,
|
|
62
|
+
className,
|
|
63
|
+
ariaLabel,
|
|
64
|
+
});
|
|
65
|
+
if (editor)
|
|
66
|
+
return editor;
|
|
67
|
+
return (_jsx(PlainTextTableField, { value: value, onChange: onChange, editable: editable, ariaLabel: ariaLabel, className: `${plainTextFieldBaseClass} ${className}` }));
|
|
68
|
+
}
|
|
69
|
+
function PlainTextTableField({ value, onChange, editable, ariaLabel, className, }) {
|
|
70
|
+
const ref = useRef(null);
|
|
71
|
+
useLayoutEffect(() => {
|
|
72
|
+
const node = ref.current;
|
|
73
|
+
if (!node || document.activeElement === node)
|
|
74
|
+
return;
|
|
75
|
+
if (node.textContent !== value)
|
|
76
|
+
node.textContent = value;
|
|
77
|
+
}, [value]);
|
|
78
|
+
const handleInput = (event) => {
|
|
79
|
+
onChange(event.currentTarget.textContent ?? "");
|
|
80
|
+
};
|
|
81
|
+
const handleKeyDown = (event) => {
|
|
82
|
+
if (event.key !== "Enter")
|
|
83
|
+
return;
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
event.currentTarget.blur();
|
|
86
|
+
};
|
|
87
|
+
const handlePaste = (event) => {
|
|
88
|
+
const text = event.clipboardData.getData("text/plain");
|
|
89
|
+
if (!text)
|
|
90
|
+
return;
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
const selection = window.getSelection();
|
|
93
|
+
if (!selection || selection.rangeCount === 0)
|
|
94
|
+
return;
|
|
95
|
+
const range = selection.getRangeAt(0);
|
|
96
|
+
range.deleteContents();
|
|
97
|
+
range.insertNode(document.createTextNode(text));
|
|
98
|
+
range.collapse(false);
|
|
99
|
+
selection.removeAllRanges();
|
|
100
|
+
selection.addRange(range);
|
|
101
|
+
onChange(event.currentTarget.textContent ?? "");
|
|
102
|
+
};
|
|
103
|
+
return (_jsx("div", { ref: ref, "data-plan-interactive": true, "data-disabled": !editable ? "true" : undefined, role: "textbox", "aria-label": ariaLabel, contentEditable: editable, suppressContentEditableWarning: true, className: className, onInput: handleInput, onKeyDown: handleKeyDown, onPaste: handlePaste }));
|
|
25
104
|
}
|
|
26
|
-
const editInputClass = "h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50";
|
|
27
|
-
const iconButtonClass = "inline-flex size-7 items-center justify-center rounded-md border border-input text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground disabled:cursor-not-allowed disabled:opacity-50";
|
|
28
|
-
const addButtonClass = "inline-flex items-center gap-1.5 rounded-md border border-input bg-transparent px-3 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground disabled:cursor-not-allowed disabled:opacity-50";
|
|
29
105
|
/**
|
|
30
106
|
* Editable grid. The schema's `columns: string[]` / `rows: string[][]` are
|
|
31
107
|
* positional/structured, which the schema auto-editor intentionally cannot
|
|
@@ -34,11 +110,13 @@ const addButtonClass = "inline-flex items-center gap-1.5 rounded-md border borde
|
|
|
34
110
|
* commits a full new `{ columns, rows }` value (re-validated upstream by the
|
|
35
111
|
* registry), keeping rows rectangular with the column count.
|
|
36
112
|
*/
|
|
37
|
-
function TableBlockEdit({ data, onChange, editable, }) {
|
|
113
|
+
function TableBlockEdit({ data, onChange, editable, ctx, }) {
|
|
38
114
|
const columns = data.columns ?? [];
|
|
39
115
|
const rows = data.rows ?? [];
|
|
40
116
|
const columnCount = columns.length;
|
|
41
|
-
const
|
|
117
|
+
const density = resolveDensity(data);
|
|
118
|
+
const spacing = densityClasses[density];
|
|
119
|
+
const commit = (next) => onChange({ ...data, ...next });
|
|
42
120
|
const setColumn = (index, value) => {
|
|
43
121
|
commit({
|
|
44
122
|
columns: columns.map((c, i) => (i === index ? value : c)),
|
|
@@ -61,6 +139,8 @@ function TableBlockEdit({ data, onChange, editable, }) {
|
|
|
61
139
|
});
|
|
62
140
|
};
|
|
63
141
|
const removeColumn = (index) => {
|
|
142
|
+
if (columns.length <= 1)
|
|
143
|
+
return;
|
|
64
144
|
commit({
|
|
65
145
|
columns: columns.filter((_, i) => i !== index),
|
|
66
146
|
rows: rows.map((row) => row.filter((_, i) => i !== index)),
|
|
@@ -79,7 +159,7 @@ function TableBlockEdit({ data, onChange, editable, }) {
|
|
|
79
159
|
const removeRow = (index) => {
|
|
80
160
|
commit({ columns, rows: rows.filter((_, i) => i !== index) });
|
|
81
161
|
};
|
|
82
|
-
return (_jsxs("div", { className: "an-table-block-editor flex flex-col gap-
|
|
162
|
+
return (_jsxs("div", { className: "an-table-block-editor group/table flex flex-col gap-2", children: [_jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: "w-full min-w-[480px] border-collapse text-left", children: [_jsx("thead", { children: _jsxs("tr", { className: "border-b border-plan-line", children: [columns.map((column, index) => (_jsx("th", { className: `group/column ${spacing.header} pr-4 align-top`, children: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(TableMarkdownField, { ctx: ctx, value: column, onChange: (value) => setColumn(index, value), editable: editable, ariaLabel: `Column ${index + 1} header`, className: tableHeaderMarkdownClass }), _jsx("button", { type: "button", "data-plan-interactive": true, "aria-label": `Remove column ${index + 1}`, className: columnHoverIconButtonClass, disabled: !editable || columns.length <= 1, onClick: () => removeColumn(index), children: _jsx(IconX, { size: 14 }) })] }) }, index))), _jsx("th", { className: "py-1 align-top", children: _jsx("button", { type: "button", "data-plan-interactive": true, "aria-label": "Add column in grid", className: tableHoverIconButtonClass, disabled: !editable, onClick: addColumn, children: _jsx(IconColumnInsertRight, { size: 16 }) }) })] }) }), _jsx("tbody", { children: rows.map((row, rowIndex) => (_jsxs("tr", { className: "group/row border-b border-plan-line", children: [Array.from({ length: columnCount }).map((_, cellIndex) => (_jsx("td", { className: `${spacing.cell} pr-4 align-top`, children: _jsx(TableMarkdownField, { ctx: ctx, value: row[cellIndex] ?? "", onChange: (value) => setCell(rowIndex, cellIndex, value), editable: editable, ariaLabel: `Row ${rowIndex + 1}, column ${cellIndex + 1}`, className: tableCellMarkdownClass }) }, cellIndex))), _jsx("td", { className: "py-2 align-top", children: _jsx("button", { type: "button", "data-plan-interactive": true, "aria-label": `Remove row ${rowIndex + 1}`, className: rowHoverIconButtonClass, disabled: !editable, onClick: () => removeRow(rowIndex), children: _jsx(IconTrash, { size: 14 }) }) })] }, rowIndex))) })] }) }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsxs("button", { type: "button", "data-plan-interactive": true, className: addButtonClass, disabled: !editable, onClick: addRow, children: [_jsx(IconRowInsertBottom, { size: 16 }), "Add row"] }), _jsxs("button", { type: "button", "data-plan-interactive": true, className: addButtonClass, disabled: !editable, onClick: addColumn, children: [_jsx(IconPlus, { size: 16 }), "Add column"] })] })] }));
|
|
83
163
|
}
|
|
84
164
|
/**
|
|
85
165
|
* The full standard `table` `BlockSpec`. Pairs the React-free
|
|
@@ -93,6 +173,7 @@ export const tableBlock = defineBlock({
|
|
|
93
173
|
Read: TableBlockRead,
|
|
94
174
|
Edit: TableBlockEdit,
|
|
95
175
|
placement: ["block"],
|
|
176
|
+
editSurface: "inline",
|
|
96
177
|
// A simple grid maps to an NFM table, so it round-trips to Notion.
|
|
97
178
|
notionCompatible: true,
|
|
98
179
|
label: "Table",
|