@agent-native/core 0.38.0 → 0.39.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/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +8 -1
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/skills.d.ts +5 -4
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +450 -125
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/blocks/BlockView.d.ts +13 -4
- package/dist/client/blocks/BlockView.d.ts.map +1 -1
- package/dist/client/blocks/BlockView.js +34 -13
- package/dist/client/blocks/BlockView.js.map +1 -1
- package/dist/client/blocks/SchemaBlockEditor.d.ts.map +1 -1
- package/dist/client/blocks/SchemaBlockEditor.js +96 -3
- package/dist/client/blocks/SchemaBlockEditor.js.map +1 -1
- package/dist/client/blocks/index.d.ts +18 -1
- package/dist/client/blocks/index.d.ts.map +1 -1
- package/dist/client/blocks/index.js +26 -1
- package/dist/client/blocks/index.js.map +1 -1
- package/dist/client/blocks/library/AnnotatedCodeBlock.d.ts +6 -0
- package/dist/client/blocks/library/AnnotatedCodeBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/AnnotatedCodeBlock.js +135 -0
- package/dist/client/blocks/library/AnnotatedCodeBlock.js.map +1 -0
- package/dist/client/blocks/library/ApiEndpointBlock.d.ts +20 -0
- package/dist/client/blocks/library/ApiEndpointBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/ApiEndpointBlock.js +131 -0
- package/dist/client/blocks/library/ApiEndpointBlock.js.map +1 -0
- package/dist/client/blocks/library/DataModelBlock.d.ts +28 -0
- package/dist/client/blocks/library/DataModelBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/DataModelBlock.js +222 -0
- package/dist/client/blocks/library/DataModelBlock.js.map +1 -0
- package/dist/client/blocks/library/DiffBlock.d.ts +6 -0
- package/dist/client/blocks/library/DiffBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/DiffBlock.js +293 -0
- package/dist/client/blocks/library/DiffBlock.js.map +1 -0
- package/dist/client/blocks/library/FileTreeBlock.d.ts +23 -0
- package/dist/client/blocks/library/FileTreeBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/FileTreeBlock.js +225 -0
- package/dist/client/blocks/library/FileTreeBlock.js.map +1 -0
- package/dist/client/blocks/library/JsonExplorerBlock.d.ts +19 -0
- package/dist/client/blocks/library/JsonExplorerBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/JsonExplorerBlock.js +171 -0
- package/dist/client/blocks/library/JsonExplorerBlock.js.map +1 -0
- package/dist/client/blocks/library/MermaidBlock.d.ts +17 -0
- package/dist/client/blocks/library/MermaidBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/MermaidBlock.js +131 -0
- package/dist/client/blocks/library/MermaidBlock.js.map +1 -0
- package/dist/client/blocks/library/OpenApiSpecBlock.d.ts +19 -0
- package/dist/client/blocks/library/OpenApiSpecBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/OpenApiSpecBlock.js +494 -0
- package/dist/client/blocks/library/OpenApiSpecBlock.js.map +1 -0
- package/dist/client/blocks/library/annotated-code.config.d.ts +58 -0
- package/dist/client/blocks/library/annotated-code.config.d.ts.map +1 -0
- package/dist/client/blocks/library/annotated-code.config.js +53 -0
- package/dist/client/blocks/library/annotated-code.config.js.map +1 -0
- package/dist/client/blocks/library/api-endpoint.config.d.ts +71 -0
- package/dist/client/blocks/library/api-endpoint.config.d.ts.map +1 -0
- package/dist/client/blocks/library/api-endpoint.config.js +91 -0
- package/dist/client/blocks/library/api-endpoint.config.js.map +1 -0
- package/dist/client/blocks/library/checklist.d.ts.map +1 -1
- package/dist/client/blocks/library/checklist.js +3 -1
- package/dist/client/blocks/library/checklist.js.map +1 -1
- package/dist/client/blocks/library/code-tabs.js +1 -1
- package/dist/client/blocks/library/code-tabs.js.map +1 -1
- package/dist/client/blocks/library/data-model.config.d.ts +72 -0
- package/dist/client/blocks/library/data-model.config.d.ts.map +1 -0
- package/dist/client/blocks/library/data-model.config.js +59 -0
- package/dist/client/blocks/library/data-model.config.js.map +1 -0
- package/dist/client/blocks/library/dev-doc-ui.d.ts +49 -0
- package/dist/client/blocks/library/dev-doc-ui.d.ts.map +1 -0
- package/dist/client/blocks/library/dev-doc-ui.js +50 -0
- package/dist/client/blocks/library/dev-doc-ui.js.map +1 -0
- package/dist/client/blocks/library/diff.config.d.ts +41 -0
- package/dist/client/blocks/library/diff.config.d.ts.map +1 -0
- package/dist/client/blocks/library/diff.config.js +34 -0
- package/dist/client/blocks/library/diff.config.js.map +1 -0
- package/dist/client/blocks/library/file-tree.config.d.ts +59 -0
- package/dist/client/blocks/library/file-tree.config.d.ts.map +1 -0
- package/dist/client/blocks/library/file-tree.config.js +45 -0
- package/dist/client/blocks/library/file-tree.config.js.map +1 -0
- package/dist/client/blocks/library/html.d.ts.map +1 -1
- package/dist/client/blocks/library/html.js +4 -1
- package/dist/client/blocks/library/html.js.map +1 -1
- package/dist/client/blocks/library/json-explorer.config.d.ts +46 -0
- package/dist/client/blocks/library/json-explorer.config.d.ts.map +1 -0
- package/dist/client/blocks/library/json-explorer.config.js +28 -0
- package/dist/client/blocks/library/json-explorer.config.js.map +1 -0
- package/dist/client/blocks/library/mermaid.config.d.ts +32 -0
- package/dist/client/blocks/library/mermaid.config.d.ts.map +1 -0
- package/dist/client/blocks/library/mermaid.config.js +24 -0
- package/dist/client/blocks/library/mermaid.config.js.map +1 -0
- package/dist/client/blocks/library/openapi-spec.config.d.ts +49 -0
- package/dist/client/blocks/library/openapi-spec.config.d.ts.map +1 -0
- package/dist/client/blocks/library/openapi-spec.config.js +24 -0
- package/dist/client/blocks/library/openapi-spec.config.js.map +1 -0
- package/dist/client/blocks/library/server-specs.d.ts +35 -0
- package/dist/client/blocks/library/server-specs.d.ts.map +1 -0
- package/dist/client/blocks/library/server-specs.js +171 -0
- package/dist/client/blocks/library/server-specs.js.map +1 -0
- package/dist/client/blocks/library/specs.d.ts +29 -0
- package/dist/client/blocks/library/specs.d.ts.map +1 -0
- package/dist/client/blocks/library/specs.js +229 -0
- package/dist/client/blocks/library/specs.js.map +1 -0
- package/dist/client/blocks/library/table.d.ts.map +1 -1
- package/dist/client/blocks/library/table.js +3 -1
- package/dist/client/blocks/library/table.js.map +1 -1
- package/dist/client/blocks/library/tabs.js +1 -1
- package/dist/client/blocks/library/tabs.js.map +1 -1
- package/dist/client/blocks/registry.d.ts +8 -0
- package/dist/client/blocks/registry.d.ts.map +1 -1
- package/dist/client/blocks/registry.js +15 -0
- package/dist/client/blocks/registry.js.map +1 -1
- package/dist/client/blocks/server.d.ts +9 -0
- package/dist/client/blocks/server.d.ts.map +1 -1
- package/dist/client/blocks/server.js +16 -0
- package/dist/client/blocks/server.js.map +1 -1
- package/dist/client/blocks/types.d.ts +40 -0
- 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 +2 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +10 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/rich-markdown-editor/DragHandle.d.ts +52 -0
- package/dist/client/rich-markdown-editor/DragHandle.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/DragHandle.js +403 -0
- package/dist/client/rich-markdown-editor/DragHandle.js.map +1 -0
- package/dist/client/rich-markdown-editor/RegistryBlockNode.d.ts +97 -0
- package/dist/client/rich-markdown-editor/RegistryBlockNode.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/RegistryBlockNode.js +214 -0
- package/dist/client/rich-markdown-editor/RegistryBlockNode.js.map +1 -0
- package/dist/client/rich-markdown-editor/RunId.d.ts +28 -0
- package/dist/client/rich-markdown-editor/RunId.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/RunId.js +60 -0
- package/dist/client/rich-markdown-editor/RunId.js.map +1 -0
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts +25 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.js +14 -5
- package/dist/client/rich-markdown-editor/SharedRichEditor.js.map +1 -1
- package/dist/client/rich-markdown-editor/gfmDoc.d.ts +24 -0
- package/dist/client/rich-markdown-editor/gfmDoc.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/gfmDoc.js +83 -0
- package/dist/client/rich-markdown-editor/gfmDoc.js.map +1 -0
- package/dist/client/rich-markdown-editor/index.d.ts +5 -0
- package/dist/client/rich-markdown-editor/index.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/index.js +5 -0
- package/dist/client/rich-markdown-editor/index.js.map +1 -1
- package/dist/client/rich-markdown-editor/registrySlashCommands.d.ts +46 -0
- package/dist/client/rich-markdown-editor/registrySlashCommands.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/registrySlashCommands.js +13 -0
- package/dist/client/rich-markdown-editor/registrySlashCommands.js.map +1 -0
- package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/useCollabReconcile.js +33 -0
- package/dist/client/rich-markdown-editor/useCollabReconcile.js.map +1 -1
- package/docs/content/template-plan.md +19 -4
- package/docs/content/visual-plans.md +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-tree.config.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/file-tree.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyBxB,MAAM,CAAC,MAAM,iBAAiB,GAAqB;IACjD,OAAO;IACP,UAAU;IACV,SAAS;IACT,SAAS;CACV,CAAC;AAsBF,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACvC,MAAM,EAAE,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\n/**\n * Pure (React-free) part of the PLAN-SPECIFIC `file-tree` block: its data schema\n * and MDX round-trip config. Shared by the server MDX adapter (`plan-mdx.ts` via\n * `plan-block-registry.ts`) and the client spec (`planBlocks.tsx`). Keeping this\n * React-free means importing it into a server module never pulls React into the\n * Nitro/SSR bundle.\n *\n * The block renders a VS Code / GitHub-explorer style file/change tree: a flat\n * list of `entries` (each a slash-delimited `path` with an optional change kind,\n * note, and code snippet) from which the RENDERER derives the nested folder tree\n * — the model never carries the folder structure, only the leaf paths. This keeps\n * the data lean and the tree always consistent with the paths.\n *\n * The schema MUST stay data-compatible with the `file-tree` member of\n * `planBlockSchema` (`plan-content.ts`), and the MDX `tag` (`FileTree`) +\n * attribute shape MUST match it so stored `.mdx` round-trips: the whole `entries`\n * array is one JSON prop (`<FileTree id … title entries={…} />`).\n */\n\n/** The kind of change applied to a file, driving its change badge. */\nexport type FileTreeChange = \"added\" | \"modified\" | \"removed\" | \"renamed\";\n\nexport const FILE_TREE_CHANGES: FileTreeChange[] = [\n \"added\",\n \"modified\",\n \"removed\",\n \"renamed\",\n];\n\n/**\n * One file in the tree. `path` is slash-delimited (`src/routes/git.ts`); the\n * renderer derives the folder structure from its segments. `change` drives the\n * change badge (A/M/D/R); `note` + `snippet` (with optional `language`) make the\n * file row expandable to show why it changes and a code preview.\n */\nexport interface FileTreeEntry {\n path: string;\n change?: FileTreeChange;\n note?: string;\n snippet?: string;\n language?: string;\n}\n\nexport interface FileTreeData {\n /** Optional heading shown above the tree (e.g. \"Files touched\"). */\n title?: string;\n entries: FileTreeEntry[];\n}\n\nconst entrySchema = z.object({\n path: z.string().trim().min(1).max(500),\n change: z.enum([\"added\", \"modified\", \"removed\", \"renamed\"]).optional(),\n note: z.string().trim().max(2_000).optional(),\n snippet: z.string().max(50_000).optional(),\n language: z.string().trim().max(40).optional(),\n}) as z.ZodType<FileTreeEntry>;\n\n/**\n * Data-compatible with the inline `file-tree` member of `planBlockSchema`\n * (`plan-content.ts`). `entries` is required (at least one file); `title` is\n * optional so a fresh tree validates from a couple of files.\n */\nexport const fileTreeSchema = z.object({\n title: z.string().trim().max(180).optional(),\n entries: z.array(entrySchema).min(1).max(200),\n}) as unknown as z.ZodType<FileTreeData>;\n\n/**\n * MDX config: `title` is a flat string attribute and the whole `entries` array is\n * serialized as one JSON prop on a self-closing element — the `<FileTree id …\n * title entries={…} />` form. `toAttrs` emits `title` then `entries` in a STABLE\n * order (the shared `prop()` encoder drops `title` when it is undefined).\n *\n * `fromAttrs` tolerates missing/partial attributes for backward-compat: a missing\n * `title` decodes to `undefined` and a missing `entries` decodes to `[]` so a\n * plan written before this block existed still parses.\n */\nexport const fileTreeMdx: BlockMdxConfig<FileTreeData> = {\n tag: \"FileTree\",\n toAttrs: (data) => ({\n title: data.title,\n entries: data.entries,\n }),\n fromAttrs: (attrs) => ({\n title: attrs.string(\"title\"),\n entries: attrs.array<FileTreeEntry>(\"entries\") ?? [],\n }),\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/html.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAqD3E,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,OAAO,EACP,KAAK,EACL,GAAG,GACJ,EAAE,cAAc,CAAC,aAAa,CAAC,2CAO/B;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,GAAG,GACJ,EAAE,cAAc,CAAC,aAAa,CAAC,2CAiE/B;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/html.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAqD3E,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,OAAO,EACP,KAAK,EACL,GAAG,GACJ,EAAE,cAAc,CAAC,aAAa,CAAC,2CAO/B;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,GAAG,GACJ,EAAE,cAAc,CAAC,aAAa,CAAC,2CAiE/B;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,gDAepB,CAAC"}
|
|
@@ -29,7 +29,7 @@ function HtmlPreview({ data, title, sanitize, }) {
|
|
|
29
29
|
}
|
|
30
30
|
/** Read-only renderer: the sandboxed iframe preview plus an optional caption. */
|
|
31
31
|
export function HtmlReadBlock({ data, blockId, title, ctx, }) {
|
|
32
|
-
return (_jsxs("section", { className: "plan-block group", "data-block-id": blockId, children: [title && _jsx("
|
|
32
|
+
return (_jsxs("section", { className: "plan-block group", "data-block-id": blockId, children: [title && _jsx("div", { className: "plan-block-label", children: title }), _jsx(HtmlPreview, { data: data, title: title, sanitize: ctx.sanitizeHtml })] }));
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Custom editor: an "Edit source" toggle that flips between the live preview and
|
|
@@ -61,6 +61,9 @@ export const htmlBlock = defineBlock({
|
|
|
61
61
|
Read: HtmlReadBlock,
|
|
62
62
|
Edit: HtmlEditBlock,
|
|
63
63
|
placement: ["block"],
|
|
64
|
+
// Config-driven: the render (a sandboxed card) differs from its source, so edit
|
|
65
|
+
// the html/css/caption from a corner button + panel rather than always-inline.
|
|
66
|
+
editSurface: "panel",
|
|
64
67
|
label: "HTML / Tailwind",
|
|
65
68
|
icon: IconCode,
|
|
66
69
|
description: "An author-supplied HTML (with optional CSS) fragment rendered in a sandboxed iframe, with inline source editing.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/html.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAsB,MAAM,kBAAkB,CAAC;AAE3E;;;;;;;;;;;;;;GAcG;AAEH,oFAAoF;AACpF,SAAS,WAAW,CAClB,IAAmB,EACnB,QAAiD;IAEjD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;IAC3B,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;IAClE,OAAO,wKAAwK,GAAG,wBAAwB,IAAI,gBAAgB,CAAC;AACjO,CAAC;AAED,SAAS,WAAW,CAAC,EACnB,IAAI,EACJ,KAAK,EACL,QAAQ,GAKT;IACC,OAAO,CACL,8BACE,iBACE,KAAK,EAAE,KAAK,IAAI,mBAAmB,EACnC,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,EACnC,OAAO,EAAC,mBAAmB,EAC3B,cAAc,EAAC,aAAa,EAC5B,SAAS,EAAC,kDAAkD,GAC5D,EACD,IAAI,CAAC,OAAO,IAAI,CACf,YAAG,SAAS,EAAC,oCAAoC,YAAE,IAAI,CAAC,OAAO,GAAK,CACrE,IACA,CACJ,CAAC;AACJ,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,aAAa,CAAC,EAC5B,IAAI,EACJ,OAAO,EACP,KAAK,EACL,GAAG,GAC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EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,iDAAiD,EAAE,CAAC;CAC3E,CAAC,CAAC","sourcesContent":["import { useState } from \"react\";\nimport { IconCode, IconEdit, IconX } from \"@tabler/icons-react\";\nimport { defineBlock } from \"../types.js\";\nimport type { BlockReadProps, BlockEditProps } from \"../types.js\";\nimport { htmlSchema, htmlMdx, type HtmlBlockData } from \"./html.config.js\";\n\n/**\n * Standard library HTML / Tailwind block. The registry form of the plan\n * `custom-html` block: an author-supplied HTML (+ optional CSS) fragment\n * rendered inside a sandboxed iframe, with an inline source editor.\n *\n * Security: the fragment is rendered in a `sandbox=\"allow-same-origin\"` iframe\n * with `referrerPolicy=\"no-referrer\"` — no scripts execute — and the schema's\n * `noFullHtmlDocument` refine rejects document/script/handler markup before it\n * is ever stored. When the app injects `ctx.sanitizeHtml`, the fragment + CSS\n * are additionally sanitized before being placed in the iframe `srcDoc`.\n *\n * Styling uses app-agnostic shadcn utility classes (`border`, `bg-muted`,\n * `text-muted-foreground`) so the block renders cleanly in any template, not\n * just the plan app.\n */\n\n/** Build the iframe document for a fragment, applying app sanitization if given. */\nfunction buildSrcDoc(\n data: HtmlBlockData,\n sanitize?: (html: string, css?: string) => string,\n): string {\n const css = data.css ?? \"\";\n const body = sanitize ? sanitize(data.html, data.css) : data.html;\n return `<!doctype html><html><head><style>body{margin:0;min-height:100%;font-family:Inter,system-ui,sans-serif;color:#1f1f1d;background:transparent;}*{box-sizing:border-box}${css}</style></head><body>${body}</body></html>`;\n}\n\nfunction HtmlPreview({\n data,\n title,\n sanitize,\n}: {\n data: HtmlBlockData;\n title?: string;\n sanitize?: (html: string, css?: string) => string;\n}) {\n return (\n <>\n <iframe\n title={title || \"Custom HTML block\"}\n srcDoc={buildSrcDoc(data, sanitize)}\n sandbox=\"allow-same-origin\"\n referrerPolicy=\"no-referrer\"\n className=\"mt-4 h-[360px] w-full rounded-xl border bg-muted\"\n />\n {data.caption && (\n <p className=\"mt-3 text-sm text-muted-foreground\">{data.caption}</p>\n )}\n </>\n );\n}\n\n/** Read-only renderer: the sandboxed iframe preview plus an optional caption. */\nexport function HtmlReadBlock({\n data,\n blockId,\n title,\n ctx,\n}: BlockReadProps<HtmlBlockData>) {\n return (\n <section className=\"plan-block group\" data-block-id={blockId}>\n {title && <h2>{title}</h2>}\n <HtmlPreview data={data} title={title} sanitize={ctx.sanitizeHtml} />\n </section>\n );\n}\n\n/**\n * Custom editor: an \"Edit source\" toggle that flips between the live preview and\n * inline HTML + CSS textareas (ported from the plan `CustomHtmlBlock`). The\n * title is rendered by the registry's edit-mode section wrapper, so this only\n * renders the toggle + content. Edits commit the merged data via `onChange`,\n * which the app routes through its generic `update-block` patch (re-validated by\n * the app schema).\n */\nexport function HtmlEditBlock({\n data,\n onChange,\n editable,\n title,\n ctx,\n}: BlockEditProps<HtmlBlockData>) {\n const [editing, setEditing] = useState(false);\n const [html, setHtml] = useState(data.html);\n const [css, setCss] = useState(data.css ?? \"\");\n\n return (\n <div className=\"plan-html-block group\" data-an-block-edit>\n <div className=\"flex items-start justify-end gap-4\">\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n className=\"inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground\"\n onClick={() => setEditing((value) => !value)}\n >\n {editing ? (\n <IconX className=\"size-4\" />\n ) : (\n <IconEdit className=\"size-4\" />\n )}\n {editing ? \"Cancel\" : \"Edit source\"}\n </button>\n )}\n </div>\n {editing ? (\n <div className=\"mt-2 grid gap-3\" data-plan-interactive>\n <textarea\n value={html}\n onChange={(event) => setHtml(event.target.value)}\n className=\"flex min-h-48 w-full rounded-md border border-input bg-transparent px-3 py-2 font-mono text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n placeholder=\"HTML fragment\"\n />\n <textarea\n value={css}\n onChange={(event) => setCss(event.target.value)}\n className=\"flex min-h-32 w-full rounded-md border border-input bg-transparent px-3 py-2 font-mono text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n placeholder=\"Optional CSS\"\n />\n <div className=\"flex justify-end gap-2\">\n <button\n type=\"button\"\n data-plan-interactive\n className=\"inline-flex h-9 items-center rounded-md px-4 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground\"\n onClick={() => setEditing(false)}\n >\n Cancel\n </button>\n <button\n type=\"button\"\n data-plan-interactive\n className=\"inline-flex h-9 items-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90\"\n onClick={() => {\n onChange({ ...data, html, css: css || undefined });\n setEditing(false);\n }}\n >\n Save\n </button>\n </div>\n </div>\n ) : (\n <HtmlPreview data={data} title={title} sanitize={ctx.sanitizeHtml} />\n )}\n </div>\n );\n}\n\n/**\n * The standard HTML / Tailwind block spec. Both apps register this; the plan app\n * registers the matching React-free `{ schema, mdx }` server-side via\n * `html.config.ts`. `empty()` seeds a friendly starter fragment for slash\n * insertion.\n */\nexport const htmlBlock = defineBlock<HtmlBlockData>({\n type: \"custom-html\",\n schema: htmlSchema,\n mdx: htmlMdx,\n Read: HtmlReadBlock,\n Edit: HtmlEditBlock,\n placement: [\"block\"],\n label: \"HTML / Tailwind\",\n icon: IconCode,\n description:\n \"An author-supplied HTML (with optional CSS) fragment rendered in a sandboxed iframe, with inline source editing.\",\n empty: () => ({ html: '<div class=\"p-6\">Edit this HTML fragment…</div>' }),\n});\n"]}
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/html.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,UAAU,EAA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c,GAC1B,EACF,eAAK,SAAS,EAAC,wBAAwB,aACrC,iBACE,IAAI,EAAC,QAAQ,iCAEb,SAAS,EAAC,+IAA+I,EACzJ,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,uBAGzB,EACT,iBACE,IAAI,EAAC,QAAQ,iCAEb,SAAS,EAAC,kJAAkJ,EAC5J,OAAO,EAAE,GAAG,EAAE;oCACZ,QAAQ,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,SAAS,EAAE,CAAC,CAAC;oCACnD,UAAU,CAAC,KAAK,CAAC,CAAC;gCACpB,CAAC,qBAGM,IACL,IACF,CACP,CAAC,CAAC,CAAC,CACF,KAAC,WAAW,IAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,CAAC,YAAY,GAAI,CACtE,IACG,CACP,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAgB;IAClD,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,UAAU;IAClB,GAAG,EAAE,OAAO;IACZ,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,aAAa;IACnB,SAAS,EAAE,CAAC,OAAO,CAAC;IACpB,gFAAgF;IAChF,+EAA+E;IAC/E,WAAW,EAAE,OAAO;IACpB,KAAK,EAAE,iBAAiB;IACxB,IAAI,EAAE,QAAQ;IACd,WAAW,EACT,kHAAkH;IACpH,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,iDAAiD,EAAE,CAAC;CAC3E,CAAC,CAAC","sourcesContent":["import { useState } from \"react\";\nimport { IconCode, IconEdit, IconX } from \"@tabler/icons-react\";\nimport { defineBlock } from \"../types.js\";\nimport type { BlockReadProps, BlockEditProps } from \"../types.js\";\nimport { htmlSchema, htmlMdx, type HtmlBlockData } from \"./html.config.js\";\n\n/**\n * Standard library HTML / Tailwind block. The registry form of the plan\n * `custom-html` block: an author-supplied HTML (+ optional CSS) fragment\n * rendered inside a sandboxed iframe, with an inline source editor.\n *\n * Security: the fragment is rendered in a `sandbox=\"allow-same-origin\"` iframe\n * with `referrerPolicy=\"no-referrer\"` — no scripts execute — and the schema's\n * `noFullHtmlDocument` refine rejects document/script/handler markup before it\n * is ever stored. When the app injects `ctx.sanitizeHtml`, the fragment + CSS\n * are additionally sanitized before being placed in the iframe `srcDoc`.\n *\n * Styling uses app-agnostic shadcn utility classes (`border`, `bg-muted`,\n * `text-muted-foreground`) so the block renders cleanly in any template, not\n * just the plan app.\n */\n\n/** Build the iframe document for a fragment, applying app sanitization if given. */\nfunction buildSrcDoc(\n data: HtmlBlockData,\n sanitize?: (html: string, css?: string) => string,\n): string {\n const css = data.css ?? \"\";\n const body = sanitize ? sanitize(data.html, data.css) : data.html;\n return `<!doctype html><html><head><style>body{margin:0;min-height:100%;font-family:Inter,system-ui,sans-serif;color:#1f1f1d;background:transparent;}*{box-sizing:border-box}${css}</style></head><body>${body}</body></html>`;\n}\n\nfunction HtmlPreview({\n data,\n title,\n sanitize,\n}: {\n data: HtmlBlockData;\n title?: string;\n sanitize?: (html: string, css?: string) => string;\n}) {\n return (\n <>\n <iframe\n title={title || \"Custom HTML block\"}\n srcDoc={buildSrcDoc(data, sanitize)}\n sandbox=\"allow-same-origin\"\n referrerPolicy=\"no-referrer\"\n className=\"mt-4 h-[360px] w-full rounded-xl border bg-muted\"\n />\n {data.caption && (\n <p className=\"mt-3 text-sm text-muted-foreground\">{data.caption}</p>\n )}\n </>\n );\n}\n\n/** Read-only renderer: the sandboxed iframe preview plus an optional caption. */\nexport function HtmlReadBlock({\n data,\n blockId,\n title,\n ctx,\n}: BlockReadProps<HtmlBlockData>) {\n return (\n <section className=\"plan-block group\" data-block-id={blockId}>\n {title && <div className=\"plan-block-label\">{title}</div>}\n <HtmlPreview data={data} title={title} sanitize={ctx.sanitizeHtml} />\n </section>\n );\n}\n\n/**\n * Custom editor: an \"Edit source\" toggle that flips between the live preview and\n * inline HTML + CSS textareas (ported from the plan `CustomHtmlBlock`). The\n * title is rendered by the registry's edit-mode section wrapper, so this only\n * renders the toggle + content. Edits commit the merged data via `onChange`,\n * which the app routes through its generic `update-block` patch (re-validated by\n * the app schema).\n */\nexport function HtmlEditBlock({\n data,\n onChange,\n editable,\n title,\n ctx,\n}: BlockEditProps<HtmlBlockData>) {\n const [editing, setEditing] = useState(false);\n const [html, setHtml] = useState(data.html);\n const [css, setCss] = useState(data.css ?? \"\");\n\n return (\n <div className=\"plan-html-block group\" data-an-block-edit>\n <div className=\"flex items-start justify-end gap-4\">\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n className=\"inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground\"\n onClick={() => setEditing((value) => !value)}\n >\n {editing ? (\n <IconX className=\"size-4\" />\n ) : (\n <IconEdit className=\"size-4\" />\n )}\n {editing ? \"Cancel\" : \"Edit source\"}\n </button>\n )}\n </div>\n {editing ? (\n <div className=\"mt-2 grid gap-3\" data-plan-interactive>\n <textarea\n value={html}\n onChange={(event) => setHtml(event.target.value)}\n className=\"flex min-h-48 w-full rounded-md border border-input bg-transparent px-3 py-2 font-mono text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n placeholder=\"HTML fragment\"\n />\n <textarea\n value={css}\n onChange={(event) => setCss(event.target.value)}\n className=\"flex min-h-32 w-full rounded-md border border-input bg-transparent px-3 py-2 font-mono text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n placeholder=\"Optional CSS\"\n />\n <div className=\"flex justify-end gap-2\">\n <button\n type=\"button\"\n data-plan-interactive\n className=\"inline-flex h-9 items-center rounded-md px-4 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground\"\n onClick={() => setEditing(false)}\n >\n Cancel\n </button>\n <button\n type=\"button\"\n data-plan-interactive\n className=\"inline-flex h-9 items-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90\"\n onClick={() => {\n onChange({ ...data, html, css: css || undefined });\n setEditing(false);\n }}\n >\n Save\n </button>\n </div>\n </div>\n ) : (\n <HtmlPreview data={data} title={title} sanitize={ctx.sanitizeHtml} />\n )}\n </div>\n );\n}\n\n/**\n * The standard HTML / Tailwind block spec. Both apps register this; the plan app\n * registers the matching React-free `{ schema, mdx }` server-side via\n * `html.config.ts`. `empty()` seeds a friendly starter fragment for slash\n * insertion.\n */\nexport const htmlBlock = defineBlock<HtmlBlockData>({\n type: \"custom-html\",\n schema: htmlSchema,\n mdx: htmlMdx,\n Read: HtmlReadBlock,\n Edit: HtmlEditBlock,\n placement: [\"block\"],\n // Config-driven: the render (a sandboxed card) differs from its source, so edit\n // the html/css/caption from a corner button + panel rather than always-inline.\n editSurface: \"panel\",\n label: \"HTML / Tailwind\",\n icon: IconCode,\n description:\n \"An author-supplied HTML (with optional CSS) fragment rendered in a sandboxed iframe, with inline source editing.\",\n empty: () => ({ html: '<div class=\"p-6\">Edit this HTML fragment…</div>' }),\n});\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { BlockMdxConfig } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Pure (React-free) part of the PLAN-SPECIFIC `json-explorer` block: its data
|
|
5
|
+
* schema and MDX round-trip config. Shared by the server MDX adapter
|
|
6
|
+
* (`plan-mdx.ts` via `plan-block-registry.ts`) and the client spec
|
|
7
|
+
* (`planBlocks.tsx`). Keeping this React-free means importing it into a server
|
|
8
|
+
* module never pulls React into the Nitro/SSR bundle.
|
|
9
|
+
*
|
|
10
|
+
* The block renders a browser-devtools / Postman-style collapsible JSON tree:
|
|
11
|
+
* object/array nodes show a chevron + a one-line summary ("{…} 3 keys" /
|
|
12
|
+
* "[…] 5 items") and expand/collapse; leaf values are type-colored (string =
|
|
13
|
+
* green, number = blue, boolean = violet, null = muted). The raw JSON TEXT is
|
|
14
|
+
* the source of truth (`json`), so authoring round-trips losslessly even when
|
|
15
|
+
* the JSON is invalid — the reader parses defensively and falls back to the raw
|
|
16
|
+
* text on a parse error rather than throwing.
|
|
17
|
+
*
|
|
18
|
+
* The schema MUST stay data-compatible with the inline `json-explorer` member of
|
|
19
|
+
* `planBlockSchema` (`plan-content.ts`), and the MDX `tag` (`Json`) +
|
|
20
|
+
* attribute shape MUST match the `<Json title json collapsedDepth />` encoding so
|
|
21
|
+
* stored `.mdx` round-trips. `json` lives in the `json` ATTRIBUTE (not MDX
|
|
22
|
+
* children) — the shared `prop()` encoder round-trips multiline strings cleanly,
|
|
23
|
+
* and keeping it an attribute avoids the payload being reflowed as prose.
|
|
24
|
+
*/
|
|
25
|
+
export interface JsonExplorerData {
|
|
26
|
+
/** Optional heading shown above the tree. */
|
|
27
|
+
title?: string;
|
|
28
|
+
/** Raw JSON text — the source of truth, parsed defensively at render time. */
|
|
29
|
+
json: string;
|
|
30
|
+
/**
|
|
31
|
+
* Depth beyond which nodes start collapsed (default 1). Nodes at a depth `<`
|
|
32
|
+
* this value render expanded; deeper nodes render collapsed until clicked.
|
|
33
|
+
*/
|
|
34
|
+
collapsedDepth?: number;
|
|
35
|
+
}
|
|
36
|
+
export declare const jsonExplorerSchema: z.ZodType<JsonExplorerData>;
|
|
37
|
+
/**
|
|
38
|
+
* MDX config: `title`, `json`, and `collapsedDepth` are flat attributes — the
|
|
39
|
+
* `<Json id … title json collapsedDepth />` self-closing form. Insertion order
|
|
40
|
+
* of `toAttrs` is the on-disk attribute order (`title` → `json` →
|
|
41
|
+
* `collapsedDepth`). `fromAttrs` mirrors a forgiving parse (`json ?? ""`,
|
|
42
|
+
* `title`/`collapsedDepth` undefined when absent) so a plan missing an attribute
|
|
43
|
+
* still parses.
|
|
44
|
+
*/
|
|
45
|
+
export declare const jsonExplorerMdx: BlockMdxConfig<JsonExplorerData>;
|
|
46
|
+
//# sourceMappingURL=json-explorer.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-explorer.config.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/json-explorer.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,kBAAkB,EAId,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE7C;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,gBAAgB,CAY5D,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const jsonExplorerSchema = z.object({
|
|
3
|
+
title: z.string().trim().max(200).optional(),
|
|
4
|
+
json: z.string().max(200_000),
|
|
5
|
+
collapsedDepth: z.number().int().min(0).max(20).optional(),
|
|
6
|
+
});
|
|
7
|
+
/**
|
|
8
|
+
* MDX config: `title`, `json`, and `collapsedDepth` are flat attributes — the
|
|
9
|
+
* `<Json id … title json collapsedDepth />` self-closing form. Insertion order
|
|
10
|
+
* of `toAttrs` is the on-disk attribute order (`title` → `json` →
|
|
11
|
+
* `collapsedDepth`). `fromAttrs` mirrors a forgiving parse (`json ?? ""`,
|
|
12
|
+
* `title`/`collapsedDepth` undefined when absent) so a plan missing an attribute
|
|
13
|
+
* still parses.
|
|
14
|
+
*/
|
|
15
|
+
export const jsonExplorerMdx = {
|
|
16
|
+
tag: "Json",
|
|
17
|
+
toAttrs: (data) => ({
|
|
18
|
+
title: data.title,
|
|
19
|
+
json: data.json,
|
|
20
|
+
collapsedDepth: data.collapsedDepth,
|
|
21
|
+
}),
|
|
22
|
+
fromAttrs: (attrs) => ({
|
|
23
|
+
json: attrs.string("json") ?? "",
|
|
24
|
+
title: attrs.string("title"),
|
|
25
|
+
collapsedDepth: attrs.number("collapsedDepth"),
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=json-explorer.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-explorer.config.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/json-explorer.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAsCxB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IAC5C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC;IAC7B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC3D,CAA2C,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAqC;IAC/D,GAAG,EAAE,MAAM;IACX,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAClB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,cAAc,EAAE,IAAI,CAAC,cAAc;KACpC,CAAC;IACF,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACrB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAChC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;QAC5B,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,gBAAgB,CAAC;KAC/C,CAAC;CACH,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { BlockMdxConfig } from \"../types.js\";\n\n/**\n * Pure (React-free) part of the PLAN-SPECIFIC `json-explorer` block: its data\n * schema and MDX round-trip config. Shared by the server MDX adapter\n * (`plan-mdx.ts` via `plan-block-registry.ts`) and the client spec\n * (`planBlocks.tsx`). Keeping this React-free means importing it into a server\n * module never pulls React into the Nitro/SSR bundle.\n *\n * The block renders a browser-devtools / Postman-style collapsible JSON tree:\n * object/array nodes show a chevron + a one-line summary (\"{…} 3 keys\" /\n * \"[…] 5 items\") and expand/collapse; leaf values are type-colored (string =\n * green, number = blue, boolean = violet, null = muted). The raw JSON TEXT is\n * the source of truth (`json`), so authoring round-trips losslessly even when\n * the JSON is invalid — the reader parses defensively and falls back to the raw\n * text on a parse error rather than throwing.\n *\n * The schema MUST stay data-compatible with the inline `json-explorer` member of\n * `planBlockSchema` (`plan-content.ts`), and the MDX `tag` (`Json`) +\n * attribute shape MUST match the `<Json title json collapsedDepth />` encoding so\n * stored `.mdx` round-trips. `json` lives in the `json` ATTRIBUTE (not MDX\n * children) — the shared `prop()` encoder round-trips multiline strings cleanly,\n * and keeping it an attribute avoids the payload being reflowed as prose.\n */\n\nexport interface JsonExplorerData {\n /** Optional heading shown above the tree. */\n title?: string;\n /** Raw JSON text — the source of truth, parsed defensively at render time. */\n json: string;\n /**\n * Depth beyond which nodes start collapsed (default 1). Nodes at a depth `<`\n * this value render expanded; deeper nodes render collapsed until clicked.\n */\n collapsedDepth?: number;\n}\n\nexport const jsonExplorerSchema = z.object({\n title: z.string().trim().max(200).optional(),\n json: z.string().max(200_000),\n collapsedDepth: z.number().int().min(0).max(20).optional(),\n}) as unknown as z.ZodType<JsonExplorerData>;\n\n/**\n * MDX config: `title`, `json`, and `collapsedDepth` are flat attributes — the\n * `<Json id … title json collapsedDepth />` self-closing form. Insertion order\n * of `toAttrs` is the on-disk attribute order (`title` → `json` →\n * `collapsedDepth`). `fromAttrs` mirrors a forgiving parse (`json ?? \"\"`,\n * `title`/`collapsedDepth` undefined when absent) so a plan missing an attribute\n * still parses.\n */\nexport const jsonExplorerMdx: BlockMdxConfig<JsonExplorerData> = {\n tag: \"Json\",\n toAttrs: (data) => ({\n title: data.title,\n json: data.json,\n collapsedDepth: data.collapsedDepth,\n }),\n fromAttrs: (attrs) => ({\n json: attrs.string(\"json\") ?? \"\",\n title: attrs.string(\"title\"),\n collapsedDepth: attrs.number(\"collapsedDepth\"),\n }),\n};\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { BlockMdxConfig } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Pure (React-free) part of the PLAN-SPECIFIC mermaid block: its data schema and
|
|
5
|
+
* MDX round-trip config. Shared by the server MDX adapter (`plan-mdx.ts` via
|
|
6
|
+
* `plan-block-registry.ts`) and the client spec (`planBlocks.tsx`). Keeping this
|
|
7
|
+
* React-free means importing it into a server module never pulls React (or the
|
|
8
|
+
* client-only `mermaid` runtime) into the Nitro/SSR bundle.
|
|
9
|
+
*
|
|
10
|
+
* The schema MUST stay data-compatible with the `mermaid` branch of
|
|
11
|
+
* `planBlockSchema` (`plan-content.ts`), and the MDX `tag` + flat `source` /
|
|
12
|
+
* `caption` attribute shape MUST match the `<Mermaid source caption />` encoding
|
|
13
|
+
* so stored `.mdx` round-trips. The diagram code lives in the `source` ATTRIBUTE
|
|
14
|
+
* (not MDX children) — the shared `prop()` encoder round-trips multiline strings
|
|
15
|
+
* cleanly, and keeping it an attribute avoids the source being reflowed as prose.
|
|
16
|
+
*/
|
|
17
|
+
export interface MermaidData {
|
|
18
|
+
/** Mermaid diagram definition (flowchart/sequence/etc.) edited as raw text. */
|
|
19
|
+
source: string;
|
|
20
|
+
/** Optional short caption rendered (muted) under the diagram. */
|
|
21
|
+
caption?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare const mermaidSchema: z.ZodType<MermaidData>;
|
|
24
|
+
/**
|
|
25
|
+
* MDX config: `source` and `caption` are flat attributes — the `<Mermaid id …
|
|
26
|
+
* source caption />` self-closing form. Insertion order of `toAttrs` is the
|
|
27
|
+
* on-disk attribute order (`source` → `caption`). `fromAttrs` mirrors a
|
|
28
|
+
* forgiving parse (`source ?? ""`, `caption` undefined when absent) so a plan
|
|
29
|
+
* missing the attribute still parses.
|
|
30
|
+
*/
|
|
31
|
+
export declare const mermaidMdx: BlockMdxConfig<MermaidData>;
|
|
32
|
+
//# sourceMappingURL=mermaid.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid.config.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/mermaid.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,WAAW;IAC1B,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,aAAa,EAGT,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AAExC;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,cAAc,CAAC,WAAW,CAUlD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const mermaidSchema = z.object({
|
|
3
|
+
source: z.string().max(50_000),
|
|
4
|
+
caption: z.string().trim().max(400).optional(),
|
|
5
|
+
});
|
|
6
|
+
/**
|
|
7
|
+
* MDX config: `source` and `caption` are flat attributes — the `<Mermaid id …
|
|
8
|
+
* source caption />` self-closing form. Insertion order of `toAttrs` is the
|
|
9
|
+
* on-disk attribute order (`source` → `caption`). `fromAttrs` mirrors a
|
|
10
|
+
* forgiving parse (`source ?? ""`, `caption` undefined when absent) so a plan
|
|
11
|
+
* missing the attribute still parses.
|
|
12
|
+
*/
|
|
13
|
+
export const mermaidMdx = {
|
|
14
|
+
tag: "Mermaid",
|
|
15
|
+
toAttrs: (data) => ({
|
|
16
|
+
source: data.source,
|
|
17
|
+
caption: data.caption,
|
|
18
|
+
}),
|
|
19
|
+
fromAttrs: (attrs) => ({
|
|
20
|
+
source: attrs.string("source") ?? "",
|
|
21
|
+
caption: attrs.string("caption"),
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=mermaid.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid.config.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/mermaid.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyBxB,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC;IAC9B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CAC/C,CAAsC,CAAC;AAExC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAgC;IACrD,GAAG,EAAE,SAAS;IACd,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAClB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,OAAO,EAAE,IAAI,CAAC,OAAO;KACtB,CAAC;IACF,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACrB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;QACpC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC;KACjC,CAAC;CACH,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { BlockMdxConfig } from \"../types.js\";\n\n/**\n * Pure (React-free) part of the PLAN-SPECIFIC mermaid block: its data schema and\n * MDX round-trip config. Shared by the server MDX adapter (`plan-mdx.ts` via\n * `plan-block-registry.ts`) and the client spec (`planBlocks.tsx`). Keeping this\n * React-free means importing it into a server module never pulls React (or the\n * client-only `mermaid` runtime) into the Nitro/SSR bundle.\n *\n * The schema MUST stay data-compatible with the `mermaid` branch of\n * `planBlockSchema` (`plan-content.ts`), and the MDX `tag` + flat `source` /\n * `caption` attribute shape MUST match the `<Mermaid source caption />` encoding\n * so stored `.mdx` round-trips. The diagram code lives in the `source` ATTRIBUTE\n * (not MDX children) — the shared `prop()` encoder round-trips multiline strings\n * cleanly, and keeping it an attribute avoids the source being reflowed as prose.\n */\n\nexport interface MermaidData {\n /** Mermaid diagram definition (flowchart/sequence/etc.) edited as raw text. */\n source: string;\n /** Optional short caption rendered (muted) under the diagram. */\n caption?: string;\n}\n\nexport const mermaidSchema = z.object({\n source: z.string().max(50_000),\n caption: z.string().trim().max(400).optional(),\n}) as unknown as z.ZodType<MermaidData>;\n\n/**\n * MDX config: `source` and `caption` are flat attributes — the `<Mermaid id …\n * source caption />` self-closing form. Insertion order of `toAttrs` is the\n * on-disk attribute order (`source` → `caption`). `fromAttrs` mirrors a\n * forgiving parse (`source ?? \"\"`, `caption` undefined when absent) so a plan\n * missing the attribute still parses.\n */\nexport const mermaidMdx: BlockMdxConfig<MermaidData> = {\n tag: \"Mermaid\",\n toAttrs: (data) => ({\n source: data.source,\n caption: data.caption,\n }),\n fromAttrs: (attrs) => ({\n source: attrs.string(\"source\") ?? \"\",\n caption: attrs.string(\"caption\"),\n }),\n};\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { BlockMdxConfig } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Pure (React-free) part of the PLAN-SPECIFIC `openapi-spec` block: its data
|
|
5
|
+
* schema and MDX round-trip config. Shared by the server MDX adapter
|
|
6
|
+
* (`plan-mdx.ts` via `plan-block-registry.ts`) and the client spec
|
|
7
|
+
* (`planBlocks.tsx`). Keeping this React-free means importing it into a server
|
|
8
|
+
* module never pulls React into the Nitro/SSR bundle.
|
|
9
|
+
*
|
|
10
|
+
* This is the WHOLE-DOCUMENT counterpart to the single-endpoint `api-endpoint`
|
|
11
|
+
* block: instead of one operation, it carries a complete OpenAPI 3 / Swagger 2
|
|
12
|
+
* document (the `spec` string) and the reader renders a Redoc / Swagger-UI-style
|
|
13
|
+
* reference — operations grouped by tag, each a collapsible row (colored method
|
|
14
|
+
* pill + path + summary) expanding to params / request body / per-status
|
|
15
|
+
* responses, with `$ref` models resolved. The raw `spec` TEXT is the source of
|
|
16
|
+
* truth, so authoring round-trips losslessly even when the spec is malformed —
|
|
17
|
+
* the reader parses defensively and falls back to a graceful error rather than
|
|
18
|
+
* throwing.
|
|
19
|
+
*
|
|
20
|
+
* v1 supports JSON specs only. A YAML parser (`yaml`) is NOT a declared
|
|
21
|
+
* dependency of this package, so to avoid pulling in an undeclared/transitive
|
|
22
|
+
* module the reader parses JSON (a superset of nothing — pure `JSON.parse`).
|
|
23
|
+
* The Edit form documents the JSON-only constraint inline. When `yaml` is later
|
|
24
|
+
* added as a real dependency, the reader's `parseSpec` is the single seam to
|
|
25
|
+
* extend.
|
|
26
|
+
*
|
|
27
|
+
* The schema MUST stay data-compatible with the inline `openapi-spec` member of
|
|
28
|
+
* `planBlockSchema` (`plan-content.ts`), and the MDX `tag` (`OpenApi`) +
|
|
29
|
+
* attribute shape MUST match the `<OpenApi title spec />` encoding so stored
|
|
30
|
+
* `.mdx` round-trips. `spec` lives in the `spec` ATTRIBUTE (not MDX children) —
|
|
31
|
+
* the shared `prop()` encoder round-trips multiline strings cleanly, and keeping
|
|
32
|
+
* it an attribute avoids the payload being reflowed as prose.
|
|
33
|
+
*/
|
|
34
|
+
export interface OpenApiSpecData {
|
|
35
|
+
/** Raw OpenAPI 3 / Swagger 2 document text (JSON in v1). Source of truth. */
|
|
36
|
+
spec: string;
|
|
37
|
+
/** Optional heading shown above the reference. */
|
|
38
|
+
title?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare const openApiSpecSchema: z.ZodType<OpenApiSpecData>;
|
|
41
|
+
/**
|
|
42
|
+
* MDX config: `title` and `spec` are flat attributes — the `<OpenApi id … title
|
|
43
|
+
* spec />` self-closing form. Insertion order of `toAttrs` is the on-disk
|
|
44
|
+
* attribute order (`title` → `spec`). `fromAttrs` mirrors a forgiving parse
|
|
45
|
+
* (`spec ?? ""`, `title` undefined when absent) so a plan missing an attribute
|
|
46
|
+
* still parses.
|
|
47
|
+
*/
|
|
48
|
+
export declare const openApiSpecMdx: BlockMdxConfig<OpenApiSpecData>;
|
|
49
|
+
//# sourceMappingURL=openapi-spec.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-spec.config.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/openapi-spec.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,MAAM,WAAW,eAAe;IAC9B,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,iBAAiB,EAGb,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,EAAE,cAAc,CAAC,eAAe,CAU1D,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const openApiSpecSchema = z.object({
|
|
3
|
+
spec: z.string().max(400_000),
|
|
4
|
+
title: z.string().trim().max(200).optional(),
|
|
5
|
+
});
|
|
6
|
+
/**
|
|
7
|
+
* MDX config: `title` and `spec` are flat attributes — the `<OpenApi id … title
|
|
8
|
+
* spec />` self-closing form. Insertion order of `toAttrs` is the on-disk
|
|
9
|
+
* attribute order (`title` → `spec`). `fromAttrs` mirrors a forgiving parse
|
|
10
|
+
* (`spec ?? ""`, `title` undefined when absent) so a plan missing an attribute
|
|
11
|
+
* still parses.
|
|
12
|
+
*/
|
|
13
|
+
export const openApiSpecMdx = {
|
|
14
|
+
tag: "OpenApi",
|
|
15
|
+
toAttrs: (data) => ({
|
|
16
|
+
title: data.title,
|
|
17
|
+
spec: data.spec,
|
|
18
|
+
}),
|
|
19
|
+
fromAttrs: (attrs) => ({
|
|
20
|
+
spec: attrs.string("spec") ?? "",
|
|
21
|
+
title: attrs.string("title"),
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=openapi-spec.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-spec.config.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/openapi-spec.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA0CxB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CAC7C,CAA0C,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAoC;IAC7D,GAAG,EAAE,SAAS;IACd,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAClB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC;IACF,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACrB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAChC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;KAC7B,CAAC;CACH,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { BlockMdxConfig } from \"../types.js\";\n\n/**\n * Pure (React-free) part of the PLAN-SPECIFIC `openapi-spec` block: its data\n * schema and MDX round-trip config. Shared by the server MDX adapter\n * (`plan-mdx.ts` via `plan-block-registry.ts`) and the client spec\n * (`planBlocks.tsx`). Keeping this React-free means importing it into a server\n * module never pulls React into the Nitro/SSR bundle.\n *\n * This is the WHOLE-DOCUMENT counterpart to the single-endpoint `api-endpoint`\n * block: instead of one operation, it carries a complete OpenAPI 3 / Swagger 2\n * document (the `spec` string) and the reader renders a Redoc / Swagger-UI-style\n * reference — operations grouped by tag, each a collapsible row (colored method\n * pill + path + summary) expanding to params / request body / per-status\n * responses, with `$ref` models resolved. The raw `spec` TEXT is the source of\n * truth, so authoring round-trips losslessly even when the spec is malformed —\n * the reader parses defensively and falls back to a graceful error rather than\n * throwing.\n *\n * v1 supports JSON specs only. A YAML parser (`yaml`) is NOT a declared\n * dependency of this package, so to avoid pulling in an undeclared/transitive\n * module the reader parses JSON (a superset of nothing — pure `JSON.parse`).\n * The Edit form documents the JSON-only constraint inline. When `yaml` is later\n * added as a real dependency, the reader's `parseSpec` is the single seam to\n * extend.\n *\n * The schema MUST stay data-compatible with the inline `openapi-spec` member of\n * `planBlockSchema` (`plan-content.ts`), and the MDX `tag` (`OpenApi`) +\n * attribute shape MUST match the `<OpenApi title spec />` encoding so stored\n * `.mdx` round-trips. `spec` lives in the `spec` ATTRIBUTE (not MDX children) —\n * the shared `prop()` encoder round-trips multiline strings cleanly, and keeping\n * it an attribute avoids the payload being reflowed as prose.\n */\n\nexport interface OpenApiSpecData {\n /** Raw OpenAPI 3 / Swagger 2 document text (JSON in v1). Source of truth. */\n spec: string;\n /** Optional heading shown above the reference. */\n title?: string;\n}\n\nexport const openApiSpecSchema = z.object({\n spec: z.string().max(400_000),\n title: z.string().trim().max(200).optional(),\n}) as unknown as z.ZodType<OpenApiSpecData>;\n\n/**\n * MDX config: `title` and `spec` are flat attributes — the `<OpenApi id … title\n * spec />` self-closing form. Insertion order of `toAttrs` is the on-disk\n * attribute order (`title` → `spec`). `fromAttrs` mirrors a forgiving parse\n * (`spec ?? \"\"`, `title` undefined when absent) so a plan missing an attribute\n * still parses.\n */\nexport const openApiSpecMdx: BlockMdxConfig<OpenApiSpecData> = {\n tag: \"OpenApi\",\n toAttrs: (data) => ({\n title: data.title,\n spec: data.spec,\n }),\n fromAttrs: (attrs) => ({\n spec: attrs.string(\"spec\") ?? \"\",\n title: attrs.string(\"title\"),\n }),\n};\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type BlockSpec } from "../types.js";
|
|
2
|
+
import { type BlockRegistry } from "../registry.js";
|
|
3
|
+
/**
|
|
4
|
+
* Canonical React-free specs for the standard library, used by BOTH apps' server
|
|
5
|
+
* / shared registries (`plan-block-registry.ts`, `nfm-registry.ts`). Each carries
|
|
6
|
+
* only the parts the server path touches — `schema` + `mdx` + metadata for the
|
|
7
|
+
* agent schema export — with a render-only `Read` stub. The full client specs
|
|
8
|
+
* (with real React `Read`/`Edit`) live in `./specs.tsx`; both share the identical
|
|
9
|
+
* `schema`/`mdx` config so inline source can never drift from what renders.
|
|
10
|
+
*
|
|
11
|
+
* `table` keeps the core default `type` here; content's server registry renames
|
|
12
|
+
* it to `table-block` via {@link LibraryBlockConfigOverrides}. The descriptions
|
|
13
|
+
* are the neutral agent-schema phrasing; an app that curates a longer
|
|
14
|
+
* description for a block (e.g. plan's hand-drawn Mermaid, plan's detailed file
|
|
15
|
+
* tree) passes an override rather than re-authoring the spec.
|
|
16
|
+
*/
|
|
17
|
+
export declare const libraryBlockConfigs: BlockSpec<any>[];
|
|
18
|
+
/**
|
|
19
|
+
* Per-block overrides for {@link registerLibraryBlockConfigs}, keyed by canonical
|
|
20
|
+
* `type`. Servers tweak only the agent-facing fields that legitimately differ:
|
|
21
|
+
* content re-types `table` → `table-block`; plan curates a longer Mermaid and
|
|
22
|
+
* file-tree description. The `schema` / `mdx` config always stays shared.
|
|
23
|
+
*/
|
|
24
|
+
export type LibraryBlockConfigOverrides = Record<string, Partial<Pick<BlockSpec<any>, "type" | "label" | "description" | "notionCompatible">>>;
|
|
25
|
+
/**
|
|
26
|
+
* Register the React-free standard-library config stubs into a server / shared
|
|
27
|
+
* {@link BlockRegistry}. Both `plan-block-registry.ts` and `nfm-registry.ts` call
|
|
28
|
+
* this, then register only their app-specific block configs (plan adds callout /
|
|
29
|
+
* diagram / wireframe / question-form) on top — so the shared library lives in
|
|
30
|
+
* exactly one place across browser AND server registries.
|
|
31
|
+
*/
|
|
32
|
+
export declare function registerLibraryBlockConfigs(registry: BlockRegistry, options?: {
|
|
33
|
+
overrides?: LibraryBlockConfigOverrides;
|
|
34
|
+
}): void;
|
|
35
|
+
//# sourceMappingURL=server-specs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-specs.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/server-specs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AA0DpE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,CAAC,GAAG,CAAC,EAqI/C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GAAG,MAAM,CAC9C,MAAM,EACN,OAAO,CACL,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,aAAa,GAAG,kBAAkB,CAAC,CAC5E,CACF,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,aAAa,EACvB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,2BAA2B,CAAA;CAAO,GACxD,IAAI,CAON"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { defineBlock } from "../types.js";
|
|
2
|
+
import { registerBlocks } from "../registry.js";
|
|
3
|
+
// React-free schema + MDX config for the standard library. The matching React
|
|
4
|
+
// `Read`/`Edit` live in the full client entry; the server path only ever touches
|
|
5
|
+
// `spec.schema` / `spec.mdx`, so these configs register with a render-only stub.
|
|
6
|
+
import { checklistSchema, checklistMdx, } from "./checklist.config.js";
|
|
7
|
+
import { tableSchema, tableMdx } from "./table.config.js";
|
|
8
|
+
import { codeTabsSchema, codeTabsMdx, } from "./code-tabs.config.js";
|
|
9
|
+
import { htmlSchema, htmlMdx } from "./html.config.js";
|
|
10
|
+
import { tabsSchema, tabsMdx } from "./tabs.config.js";
|
|
11
|
+
import { mermaidSchema, mermaidMdx, } from "./mermaid.config.js";
|
|
12
|
+
import { apiEndpointSchema, apiEndpointMdx, } from "./api-endpoint.config.js";
|
|
13
|
+
import { openApiSpecSchema, openApiSpecMdx, } from "./openapi-spec.config.js";
|
|
14
|
+
import { dataModelSchema, dataModelMdx, } from "./data-model.config.js";
|
|
15
|
+
import { diffSchema, diffMdx } from "./diff.config.js";
|
|
16
|
+
import { fileTreeSchema, fileTreeMdx, } from "./file-tree.config.js";
|
|
17
|
+
import { jsonExplorerSchema, jsonExplorerMdx, } from "./json-explorer.config.js";
|
|
18
|
+
import { annotatedCodeSchema, annotatedCodeMdx, } from "./annotated-code.config.js";
|
|
19
|
+
/** Render-only stub for server / agent registries (never invoked off-browser). */
|
|
20
|
+
const ServerReadStub = () => null;
|
|
21
|
+
/**
|
|
22
|
+
* Canonical React-free specs for the standard library, used by BOTH apps' server
|
|
23
|
+
* / shared registries (`plan-block-registry.ts`, `nfm-registry.ts`). Each carries
|
|
24
|
+
* only the parts the server path touches — `schema` + `mdx` + metadata for the
|
|
25
|
+
* agent schema export — with a render-only `Read` stub. The full client specs
|
|
26
|
+
* (with real React `Read`/`Edit`) live in `./specs.tsx`; both share the identical
|
|
27
|
+
* `schema`/`mdx` config so inline source can never drift from what renders.
|
|
28
|
+
*
|
|
29
|
+
* `table` keeps the core default `type` here; content's server registry renames
|
|
30
|
+
* it to `table-block` via {@link LibraryBlockConfigOverrides}. The descriptions
|
|
31
|
+
* are the neutral agent-schema phrasing; an app that curates a longer
|
|
32
|
+
* description for a block (e.g. plan's hand-drawn Mermaid, plan's detailed file
|
|
33
|
+
* tree) passes an override rather than re-authoring the spec.
|
|
34
|
+
*/
|
|
35
|
+
export const libraryBlockConfigs = [
|
|
36
|
+
defineBlock({
|
|
37
|
+
type: "checklist",
|
|
38
|
+
schema: checklistSchema,
|
|
39
|
+
mdx: checklistMdx,
|
|
40
|
+
Read: ServerReadStub,
|
|
41
|
+
placement: ["block"],
|
|
42
|
+
notionCompatible: true,
|
|
43
|
+
label: "Checklist",
|
|
44
|
+
description: "A list of toggleable items, each with a label and an optional note.",
|
|
45
|
+
}),
|
|
46
|
+
defineBlock({
|
|
47
|
+
type: "table",
|
|
48
|
+
schema: tableSchema,
|
|
49
|
+
mdx: tableMdx,
|
|
50
|
+
Read: ServerReadStub,
|
|
51
|
+
placement: ["block"],
|
|
52
|
+
notionCompatible: true,
|
|
53
|
+
label: "Table",
|
|
54
|
+
description: "A simple grid with header columns and string rows for comparisons, parameters, or structured lists.",
|
|
55
|
+
}),
|
|
56
|
+
defineBlock({
|
|
57
|
+
type: "code-tabs",
|
|
58
|
+
schema: codeTabsSchema,
|
|
59
|
+
mdx: codeTabsMdx,
|
|
60
|
+
Read: ServerReadStub,
|
|
61
|
+
placement: ["block"],
|
|
62
|
+
label: "Code tabs",
|
|
63
|
+
description: "A vertical file tab rail of syntax-highlighted code snippets, one tab per file with an optional language and caption.",
|
|
64
|
+
}),
|
|
65
|
+
defineBlock({
|
|
66
|
+
type: "custom-html",
|
|
67
|
+
schema: htmlSchema,
|
|
68
|
+
mdx: htmlMdx,
|
|
69
|
+
Read: ServerReadStub,
|
|
70
|
+
placement: ["block"],
|
|
71
|
+
label: "HTML / Tailwind",
|
|
72
|
+
description: "An author-supplied HTML (with optional CSS) fragment rendered in a sandboxed iframe, with inline source editing.",
|
|
73
|
+
}),
|
|
74
|
+
defineBlock({
|
|
75
|
+
type: "tabs",
|
|
76
|
+
schema: tabsSchema,
|
|
77
|
+
mdx: tabsMdx,
|
|
78
|
+
Read: ServerReadStub,
|
|
79
|
+
placement: ["block", "inline"],
|
|
80
|
+
label: "Tabs",
|
|
81
|
+
description: "A horizontal pill-tab container; each tab holds its own list of blocks.",
|
|
82
|
+
}),
|
|
83
|
+
defineBlock({
|
|
84
|
+
type: "mermaid",
|
|
85
|
+
schema: mermaidSchema,
|
|
86
|
+
mdx: mermaidMdx,
|
|
87
|
+
Read: ServerReadStub,
|
|
88
|
+
placement: ["block"],
|
|
89
|
+
label: "Diagram (Mermaid)",
|
|
90
|
+
description: "A Mermaid diagram (flowchart, sequence, etc.) defined as text and rendered as a diagram.",
|
|
91
|
+
}),
|
|
92
|
+
defineBlock({
|
|
93
|
+
type: "api-endpoint",
|
|
94
|
+
schema: apiEndpointSchema,
|
|
95
|
+
mdx: apiEndpointMdx,
|
|
96
|
+
Read: ServerReadStub,
|
|
97
|
+
placement: ["block"],
|
|
98
|
+
label: "API endpoint",
|
|
99
|
+
description: "A Swagger-style API endpoint reference: a colored method pill + path, collapsed by default, expanding to params, request body, and per-status response examples.",
|
|
100
|
+
}),
|
|
101
|
+
defineBlock({
|
|
102
|
+
type: "openapi-spec",
|
|
103
|
+
schema: openApiSpecSchema,
|
|
104
|
+
mdx: openApiSpecMdx,
|
|
105
|
+
Read: ServerReadStub,
|
|
106
|
+
placement: ["block"],
|
|
107
|
+
label: "OpenAPI spec",
|
|
108
|
+
description: "A whole-document Redoc / Swagger-UI-style API reference rendered from a complete OpenAPI 3 / Swagger 2 spec (JSON).",
|
|
109
|
+
}),
|
|
110
|
+
defineBlock({
|
|
111
|
+
type: "data-model",
|
|
112
|
+
schema: dataModelSchema,
|
|
113
|
+
mdx: dataModelMdx,
|
|
114
|
+
Read: ServerReadStub,
|
|
115
|
+
placement: ["block"],
|
|
116
|
+
label: "Data model",
|
|
117
|
+
description: "An ERD / dbdiagram-style data model: entity cards with typed fields (PK/FK/nullable flags) and interactive foreign-key relations.",
|
|
118
|
+
}),
|
|
119
|
+
defineBlock({
|
|
120
|
+
type: "diff",
|
|
121
|
+
schema: diffSchema,
|
|
122
|
+
mdx: diffMdx,
|
|
123
|
+
Read: ServerReadStub,
|
|
124
|
+
placement: ["block"],
|
|
125
|
+
label: "Diff",
|
|
126
|
+
description: "A GitHub-style before/after line diff for a file, with unified or split view and added/removed line highlighting.",
|
|
127
|
+
}),
|
|
128
|
+
defineBlock({
|
|
129
|
+
type: "file-tree",
|
|
130
|
+
schema: fileTreeSchema,
|
|
131
|
+
mdx: fileTreeMdx,
|
|
132
|
+
Read: ServerReadStub,
|
|
133
|
+
placement: ["block"],
|
|
134
|
+
label: "File tree",
|
|
135
|
+
description: "A VS Code / GitHub-explorer file and change tree with per-file change badges, notes, and code snippets.",
|
|
136
|
+
}),
|
|
137
|
+
defineBlock({
|
|
138
|
+
type: "json-explorer",
|
|
139
|
+
schema: jsonExplorerSchema,
|
|
140
|
+
mdx: jsonExplorerMdx,
|
|
141
|
+
Read: ServerReadStub,
|
|
142
|
+
placement: ["block"],
|
|
143
|
+
label: "JSON explorer",
|
|
144
|
+
description: "A collapsible browser-devtools / Postman-style JSON tree with type-colored values and expand/collapse.",
|
|
145
|
+
}),
|
|
146
|
+
defineBlock({
|
|
147
|
+
type: "annotated-code",
|
|
148
|
+
schema: annotatedCodeSchema,
|
|
149
|
+
mdx: annotatedCodeMdx,
|
|
150
|
+
Read: ServerReadStub,
|
|
151
|
+
placement: ["block"],
|
|
152
|
+
label: "Annotated code",
|
|
153
|
+
description: "A line-numbered code walkthrough whose line ranges carry anchored explanatory notes.",
|
|
154
|
+
}),
|
|
155
|
+
];
|
|
156
|
+
/**
|
|
157
|
+
* Register the React-free standard-library config stubs into a server / shared
|
|
158
|
+
* {@link BlockRegistry}. Both `plan-block-registry.ts` and `nfm-registry.ts` call
|
|
159
|
+
* this, then register only their app-specific block configs (plan adds callout /
|
|
160
|
+
* diagram / wireframe / question-form) on top — so the shared library lives in
|
|
161
|
+
* exactly one place across browser AND server registries.
|
|
162
|
+
*/
|
|
163
|
+
export function registerLibraryBlockConfigs(registry, options = {}) {
|
|
164
|
+
const overrides = options.overrides ?? {};
|
|
165
|
+
const specs = libraryBlockConfigs.map((spec) => {
|
|
166
|
+
const override = overrides[spec.type];
|
|
167
|
+
return override ? { ...spec, ...override } : spec;
|
|
168
|
+
});
|
|
169
|
+
registerBlocks(registry, specs);
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=server-specs.js.map
|
|
@@ -0,0 +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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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 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"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type BlockSpec } from "../types.js";
|
|
2
|
+
import { type BlockRegistry } from "../registry.js";
|
|
3
|
+
/**
|
|
4
|
+
* The full standard library spec set, in registration order: the five fully
|
|
5
|
+
* pre-built specs (checklist, table, code-tabs, html, tabs) followed by the
|
|
6
|
+
* eight dev-doc specs. This is the single list both the plan and content browser
|
|
7
|
+
* registries register — adding a 14th library block here lands in both apps.
|
|
8
|
+
*/
|
|
9
|
+
export declare const libraryBlockSpecs: BlockSpec<any>[];
|
|
10
|
+
/**
|
|
11
|
+
* Per-block metadata overrides for {@link registerLibraryBlocks}, keyed by the
|
|
12
|
+
* canonical block `type`. Lets an app tweak the few fields that legitimately
|
|
13
|
+
* differ (a `type` rename, a tweaked `description` or `empty` seed) without
|
|
14
|
+
* re-authoring the spec. Anything omitted keeps the canonical value, so the
|
|
15
|
+
* schema / MDX config and the React `Read`/`Edit` renderers always stay shared.
|
|
16
|
+
*/
|
|
17
|
+
export type LibraryBlockOverrides = Record<string, Partial<Pick<BlockSpec<any>, "type" | "label" | "description" | "empty">>>;
|
|
18
|
+
/**
|
|
19
|
+
* Register the standard library block specs into a {@link BlockRegistry}. Both
|
|
20
|
+
* the plan and content browser registries call this, then register only their
|
|
21
|
+
* own app-specific blocks on top — so the shared library lives in exactly one
|
|
22
|
+
* place. Pass `overrides` (keyed by canonical `type`) for the small per-app
|
|
23
|
+
* differences (content re-types `table` → `table-block`; each app phrases the
|
|
24
|
+
* Mermaid description and seeds the OpenAPI example a little differently).
|
|
25
|
+
*/
|
|
26
|
+
export declare function registerLibraryBlocks(registry: BlockRegistry, options?: {
|
|
27
|
+
overrides?: LibraryBlockOverrides;
|
|
28
|
+
}): void;
|
|
29
|
+
//# sourceMappingURL=specs.d.ts.map
|
|
@@ -0,0 +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;AAsPpE;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,CAAC,GAAG,CAAC,EAO7C,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"}
|