mdx-artifacts 0.1.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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +234 -0
  3. package/README.zh-CN.md +129 -0
  4. package/agents/AGENTS.snippet.md +13 -0
  5. package/artifact-docs/examples/commentable-feedback.mdx +126 -0
  6. package/artifact-docs/examples/decision-matrix.mdx +80 -0
  7. package/artifact-docs/examples/layout-composition.mdx +216 -0
  8. package/artifact-docs/examples/streamlit-style-mixed.mdx +183 -0
  9. package/dist/lib/cli/artifact-state.d.ts +27 -0
  10. package/dist/lib/cli/artifact-state.js +115 -0
  11. package/dist/lib/cli/build.d.ts +1 -0
  12. package/dist/lib/cli/build.js +25 -0
  13. package/dist/lib/cli/components.d.ts +3 -0
  14. package/dist/lib/cli/components.js +58 -0
  15. package/dist/lib/cli/config.d.ts +2 -0
  16. package/dist/lib/cli/config.js +36 -0
  17. package/dist/lib/cli/dev.d.ts +1 -0
  18. package/dist/lib/cli/dev.js +24 -0
  19. package/dist/lib/cli/index.d.ts +2 -0
  20. package/dist/lib/cli/index.js +69 -0
  21. package/dist/lib/cli/review.d.ts +33 -0
  22. package/dist/lib/cli/review.js +390 -0
  23. package/dist/lib/cli/scaffold.d.ts +1 -0
  24. package/dist/lib/cli/scaffold.js +56 -0
  25. package/dist/lib/cli/types.d.ts +7 -0
  26. package/dist/lib/cli/types.js +1 -0
  27. package/dist/lib/cli/validate.d.ts +6 -0
  28. package/dist/lib/cli/validate.js +79 -0
  29. package/dist/lib/cli/vite-artifact.d.ts +13 -0
  30. package/dist/lib/cli/vite-artifact.js +213 -0
  31. package/dist/lib/react/components/AnnotatedCode.d.ts +19 -0
  32. package/dist/lib/react/components/AnnotatedCode.js +30 -0
  33. package/dist/lib/react/components/ArtifactState.d.ts +68 -0
  34. package/dist/lib/react/components/ArtifactState.js +286 -0
  35. package/dist/lib/react/components/Callout.d.ts +9 -0
  36. package/dist/lib/react/components/Callout.js +21 -0
  37. package/dist/lib/react/components/CodeBlock.d.ts +10 -0
  38. package/dist/lib/react/components/CodeBlock.js +28 -0
  39. package/dist/lib/react/components/Comments.d.ts +53 -0
  40. package/dist/lib/react/components/Comments.js +613 -0
  41. package/dist/lib/react/components/ComparisonSet.d.ts +24 -0
  42. package/dist/lib/react/components/ComparisonSet.js +30 -0
  43. package/dist/lib/react/components/DecisionMatrix.d.ts +16 -0
  44. package/dist/lib/react/components/DecisionMatrix.js +27 -0
  45. package/dist/lib/react/components/DiffBlock.d.ts +15 -0
  46. package/dist/lib/react/components/DiffBlock.js +24 -0
  47. package/dist/lib/react/components/ExportPanel.d.ts +7 -0
  48. package/dist/lib/react/components/ExportPanel.js +84 -0
  49. package/dist/lib/react/components/InlineText.d.ts +9 -0
  50. package/dist/lib/react/components/InlineText.js +18 -0
  51. package/dist/lib/react/components/Layout.d.ts +44 -0
  52. package/dist/lib/react/components/Layout.js +28 -0
  53. package/dist/lib/react/components/MarkdownBody.d.ts +7 -0
  54. package/dist/lib/react/components/MarkdownBody.js +36 -0
  55. package/dist/lib/react/components/OptionGrid.d.ts +13 -0
  56. package/dist/lib/react/components/OptionGrid.js +21 -0
  57. package/dist/lib/react/components/Section.d.ts +7 -0
  58. package/dist/lib/react/components/Section.js +41 -0
  59. package/dist/lib/react/components/SeverityBadge.d.ts +7 -0
  60. package/dist/lib/react/components/SeverityBadge.js +14 -0
  61. package/dist/lib/react/index.d.ts +33 -0
  62. package/dist/lib/react/index.js +16 -0
  63. package/dist/lib/react/registry.d.ts +24 -0
  64. package/dist/lib/react/registry.js +1002 -0
  65. package/dist/lib/react/styles.css +1417 -0
  66. package/docs/component-protocol.md +273 -0
  67. package/docs/component-taxonomy.md +273 -0
  68. package/docs/design.md +239 -0
  69. package/docs/design.zh-CN.md +217 -0
  70. package/docs/naming.md +123 -0
  71. package/docs/testing.md +138 -0
  72. package/package.json +90 -0
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CommentTarget } from "./Comments.js";
3
+ export function CodeBlock({ id, code, language, filename, showLineNumbers = false, highlightLines = [], className }) {
4
+ const lines = splitCodeLines(code);
5
+ const highlighted = new Set(highlightLines);
6
+ const title = filename ?? (language ? `${language} code block` : "Code block");
7
+ const targetId = id ?? `code:${slugify(filename ?? language ?? code)}`;
8
+ return (_jsx(CommentTarget, { className: classNames("ak-comment-target-section", className), description: "CodeBlock component", targetId: targetId, title: title, children: _jsxs("figure", { className: "ak-code-block", children: [(filename || language) && (_jsxs("figcaption", { className: "ak-code-header", children: [filename && _jsx("span", { className: "ak-code-filename", children: filename }), language && _jsx("span", { className: "ak-code-language", children: language })] })), _jsx("pre", { className: "ak-code-pre", children: _jsx("code", { className: language ? `language-${language}` : undefined, children: lines.map((line, index) => {
9
+ const lineNumber = index + 1;
10
+ return (_jsxs("span", { className: classNames("ak-code-line", showLineNumbers ? "ak-code-line-numbered" : undefined, highlighted.has(lineNumber) ? "ak-code-line-highlighted" : undefined), "data-line": lineNumber, children: [showLineNumbers && _jsx("span", { className: "ak-code-line-number", children: lineNumber }), _jsx("span", { className: "ak-code-line-content", children: line || "\u00a0" })] }, lineNumber));
11
+ }) }) })] }) }));
12
+ }
13
+ function splitCodeLines(code) {
14
+ const normalized = code.endsWith("\n") ? code.slice(0, -1) : code;
15
+ return normalized.split("\n");
16
+ }
17
+ function classNames(...values) {
18
+ return values.filter(Boolean).join(" ");
19
+ }
20
+ function slugify(value) {
21
+ const slug = value
22
+ .toLowerCase()
23
+ .replace(/[`*_~[\]()]/g, "")
24
+ .replace(/[^a-z0-9]+/g, "-")
25
+ .replace(/^-+|-+$/g, "")
26
+ .slice(0, 64);
27
+ return slug || "item";
28
+ }
@@ -0,0 +1,53 @@
1
+ import type { ReactNode } from "react";
2
+ import { type ArtifactStateMessage, type ArtifactStateReviewThread } from "./ArtifactState";
3
+ export { createArtifactCommentsFromState, createArtifactThreadsFromState } from "./ArtifactState";
4
+ export type ArtifactComment = {
5
+ id: string;
6
+ blockId: string;
7
+ blockTitle: string;
8
+ blockDescription?: string;
9
+ comment: string;
10
+ createdAt: string;
11
+ };
12
+ export type CommentExportValue = {
13
+ comments?: ArtifactComment[];
14
+ threads?: ArtifactReviewThread[];
15
+ };
16
+ export type ArtifactReviewMessage = ArtifactStateMessage;
17
+ export type ArtifactReviewThread = ArtifactStateReviewThread;
18
+ export type CommentLayerProps = {
19
+ children: ReactNode;
20
+ };
21
+ export type CommentableBlockProps = {
22
+ blockId: string;
23
+ title: string;
24
+ description?: string;
25
+ children: ReactNode;
26
+ className?: string;
27
+ };
28
+ export type CommentTargetProps = {
29
+ targetId: string;
30
+ title: string;
31
+ description?: string;
32
+ children: ReactNode;
33
+ className?: string;
34
+ };
35
+ export type CommentExportFormat = "markdown" | "json";
36
+ export type CommentExportProps = {
37
+ title?: string;
38
+ formats?: CommentExportFormat[];
39
+ };
40
+ export type AddCommentInput = {
41
+ blockId: string;
42
+ blockTitle: string;
43
+ blockDescription?: string;
44
+ comment: string;
45
+ };
46
+ export declare function CommentLayer({ children }: CommentLayerProps): import("react/jsx-runtime").JSX.Element;
47
+ export declare function CommentableBlock({ blockId, title, description, children, className }: CommentableBlockProps): import("react/jsx-runtime").JSX.Element;
48
+ export declare function CommentTarget({ targetId, title, description, children, className }: CommentTargetProps): import("react/jsx-runtime").JSX.Element;
49
+ export declare function CommentExport({ title, formats }: CommentExportProps): import("react/jsx-runtime").JSX.Element;
50
+ export declare function useOptionalCommentExportValue(): CommentExportValue | undefined;
51
+ export declare function serializeCommentsToMarkdown(value: CommentExportValue): string;
52
+ export declare function createArtifactComment(input: AddCommentInput, id: string, createdAt: string): ArtifactComment | null;
53
+ export declare function createArtifactThread(input: AddCommentInput, threadId: string, messageId: string, createdAt: string): ArtifactReviewThread | null;