@fabrika/canvas-kernel 0.1.45 → 0.2.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 (66) hide show
  1. package/README.md +33 -67
  2. package/index.ts +19 -83
  3. package/package.json +68 -72
  4. package/src/client/AnnotationProvider.tsx +227 -268
  5. package/src/client/AnnotationSidebar.tsx +392 -338
  6. package/src/client/FileIcon.tsx +106 -65
  7. package/src/client/PlanRenderer.tsx +607 -551
  8. package/src/client/RenderErrorContext.ts +7 -7
  9. package/src/client/ResponsePreview.tsx +192 -173
  10. package/src/client/annotationDom.ts +43 -97
  11. package/src/client/annotationDraft.ts +98 -92
  12. package/src/client/appContext.tsx +40 -40
  13. package/src/client/components/Callout.tsx +20 -20
  14. package/src/client/components/Checklist.tsx +28 -28
  15. package/src/client/components/Choice.tsx +178 -159
  16. package/src/client/components/CodeBlock.tsx +26 -26
  17. package/src/client/components/Diff.tsx +17 -17
  18. package/src/client/components/FilePreview.tsx +99 -74
  19. package/src/client/components/Image.tsx +41 -39
  20. package/src/client/components/Markdown.tsx +33 -32
  21. package/src/client/components/Mermaid.tsx +592 -542
  22. package/src/client/components/Note.tsx +8 -8
  23. package/src/client/components/Priority.tsx +11 -11
  24. package/src/client/components/ResponseNote.tsx +17 -15
  25. package/src/client/components/Section.tsx +28 -26
  26. package/src/client/components/Table.tsx +34 -29
  27. package/src/client/components/Task.tsx +58 -60
  28. package/src/client/components/UserInput.tsx +169 -152
  29. package/src/client/components/index.ts +16 -16
  30. package/src/client/components/renderMarkdownChildren.tsx +86 -68
  31. package/src/client/diffLines.ts +51 -39
  32. package/src/client/generateMarkdown.ts +197 -191
  33. package/src/client/hostContext.tsx +34 -34
  34. package/src/client/index.ts +43 -125
  35. package/src/client/preact-all.ts +4 -4
  36. package/src/client/runtime.ts +58 -111
  37. package/src/client/styles.css +1 -74
  38. package/src/engine/compiler.ts +316 -313
  39. package/src/engine/paths.ts +44 -44
  40. package/src/engine/session.ts +623 -618
  41. package/src/engine/watcher.ts +63 -60
  42. package/src/engine/websocket.ts +123 -121
  43. package/annotate.ts +0 -94
  44. package/daemon.ts +0 -46
  45. package/src/client/AnnotationDraftFooter.tsx +0 -76
  46. package/src/client/AnnotationEditor.tsx +0 -320
  47. package/src/client/AnnotationList.tsx +0 -190
  48. package/src/client/Popover.tsx +0 -361
  49. package/src/client/SessionContext.tsx +0 -3
  50. package/src/client/annotationContext.ts +0 -130
  51. package/src/client/annotationMarkdown.ts +0 -102
  52. package/src/client/annotationTarget.ts +0 -73
  53. package/src/client/blockTarget.ts +0 -127
  54. package/src/client/highlightRange.ts +0 -262
  55. package/src/client/popoverPosition.ts +0 -46
  56. package/src/client/regionTarget.ts +0 -180
  57. package/src/client/testing/dom.ts +0 -74
  58. package/src/client/textTarget.ts +0 -31
  59. package/src/client/useRegionAnnotation.tsx +0 -188
  60. package/src/client/useTextAnnotation.tsx +0 -194
  61. package/src/client/utils.ts +0 -33
  62. package/src/engine/channel.ts +0 -278
  63. package/src/engine/http-utils.ts +0 -14
  64. package/src/engine/lifecycle.ts +0 -302
  65. package/src/engine/router.ts +0 -16
  66. package/src/engine/waiter.ts +0 -188
@@ -1,14 +1,14 @@
1
- import React from "react";
2
- import { renderMarkdownChildren } from "./renderMarkdownChildren";
1
+ import React from 'react'
2
+ import { renderMarkdownChildren } from './renderMarkdownChildren'
3
3
 
4
4
  interface NoteProps {
5
- children?: React.ReactNode;
5
+ children?: React.ReactNode
6
6
  }
7
7
 
8
8
  export function Note({ children }: NoteProps) {
9
- return (
10
- <div className="relative bg-bg-elevated rounded-lg px-5 py-4 mt-3 text-body text-text-secondary italic leading-relaxed" data-md="note">
11
- {renderMarkdownChildren(children)}
12
- </div>
13
- );
9
+ return (
10
+ <div className="relative bg-bg-elevated rounded-lg px-5 py-4 mt-3 text-body text-text-secondary italic leading-relaxed" data-md="note">
11
+ {renderMarkdownChildren(children)}
12
+ </div>
13
+ )
14
14
  }
@@ -1,19 +1,19 @@
1
- import React from "react";
1
+ import React from 'react'
2
2
 
3
3
  interface PriorityProps {
4
- level: "high" | "medium" | "low";
4
+ level: 'high' | 'medium' | 'low'
5
5
  }
6
6
 
7
7
  const config = {
8
- high: "text-accent-red bg-accent-red-muted",
9
- medium: "text-accent-amber bg-accent-amber-muted",
10
- low: "text-text-tertiary bg-border-subtle",
11
- };
8
+ high: 'text-accent-red bg-accent-red-muted',
9
+ medium: 'text-accent-amber bg-accent-amber-muted',
10
+ low: 'text-text-tertiary bg-border-subtle',
11
+ }
12
12
 
13
13
  export function Priority({ level }: PriorityProps) {
14
- return (
15
- <span className={`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${config[level]}`} data-md="priority" data-md-level={level}>
16
- {level}
17
- </span>
18
- );
14
+ return (
15
+ <span className={`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${config[level]}`} data-md="priority" data-md-level={level}>
16
+ {level}
17
+ </span>
18
+ )
19
19
  }
@@ -1,19 +1,21 @@
1
- import React from "react";
2
- import { autoResizeTextarea } from "../utils";
1
+ import { autoResizeTextarea } from '@fabrika/annotations'
2
+ import React from 'react'
3
3
 
4
4
  /** Seamless note input for response components */
5
5
  export function ResponseNote({ note, onChange }: { show?: boolean; note: string; onToggle?: () => void; onChange: (n: string) => void }) {
6
- return (
7
- <div className="mt-1.5">
8
- <textarea
9
- value={note}
10
- onChange={(e) => onChange(e.currentTarget.value)}
11
- className="w-full bg-transparent text-[12px] font-body text-text-primary resize-none focus:outline-none border-none placeholder:text-text-disabled transition-colors min-h-[20px] p-0 leading-relaxed"
12
- placeholder="Add a note..."
13
- rows={1}
14
- onInput={(e) => autoResizeTextarea(e.currentTarget)}
15
- ref={(el) => { if (el) autoResizeTextarea(el); }}
16
- />
17
- </div>
18
- );
6
+ return (
7
+ <div className="mt-1.5">
8
+ <textarea
9
+ value={note}
10
+ onChange={(e) => onChange(e.currentTarget.value)}
11
+ className="w-full bg-transparent text-[12px] font-body text-text-primary resize-none focus:outline-none border-none placeholder:text-text-disabled transition-colors min-h-[20px] p-0 leading-relaxed"
12
+ placeholder="Add a note..."
13
+ rows={1}
14
+ onInput={(e) => autoResizeTextarea(e.currentTarget)}
15
+ ref={(el) => {
16
+ if (el) autoResizeTextarea(el)
17
+ }}
18
+ />
19
+ </div>
20
+ )
19
21
  }
@@ -1,33 +1,35 @@
1
- import React, { useState } from "react";
2
- import { renderMarkdownChildren } from "./renderMarkdownChildren";
1
+ import React, { useState } from 'react'
2
+ import { renderMarkdownChildren } from './renderMarkdownChildren'
3
3
 
4
4
  interface SectionProps {
5
- title: string;
6
- children?: React.ReactNode;
5
+ title: string
6
+ children?: React.ReactNode
7
7
  }
8
8
 
9
9
  export function Section({ title, children }: SectionProps) {
10
- const [collapsed, setCollapsed] = useState(false);
10
+ const [collapsed, setCollapsed] = useState(false)
11
11
 
12
- return (
13
- <div className="relative mb-8 p-4 group/section" data-md="section" data-md-title={title}>
14
- <div className="relative mb-2">
15
- <button
16
- onClick={() => setCollapsed(!collapsed)}
17
- className={`absolute -left-8 top-1/2 -translate-y-1/2 text-text-tertiary opacity-0 group-hover/section:opacity-50 hover:!opacity-100 transition-all duration-150 p-0.5 ${collapsed ? "-rotate-90" : ""}`}
18
- >
19
- <svg width="14" height="14" viewBox="0 0 12 12" fill="none">
20
- <path d="M3 4.5L6 7.5L9 4.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
21
- </svg>
22
- </button>
23
- <h2
24
- className="font-heading text-section text-text-primary"
25
- style={{ fontWeight: 400 }}
26
- >
27
- {title}
28
- </h2>
29
- </div>
30
- <div className={collapsed ? "mt-6 hidden" : "mt-6"}>{renderMarkdownChildren(children)}</div>
31
- </div>
32
- );
12
+ return (
13
+ <div className="relative mb-8 p-4 group/section" data-md="section" data-md-title={title}>
14
+ <div className="relative mb-2">
15
+ <button
16
+ onClick={() => setCollapsed(!collapsed)}
17
+ className={`absolute -left-8 top-1/2 -translate-y-1/2 text-text-tertiary opacity-0 group-hover/section:opacity-50 hover:!opacity-100 transition-all duration-150 p-0.5 ${
18
+ collapsed ? '-rotate-90' : ''
19
+ }`}
20
+ >
21
+ <svg width="14" height="14" viewBox="0 0 12 12" fill="none">
22
+ <path d="M3 4.5L6 7.5L9 4.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
23
+ </svg>
24
+ </button>
25
+ <h2
26
+ className="font-heading text-section text-text-primary"
27
+ style={{ fontWeight: 400 }}
28
+ >
29
+ {title}
30
+ </h2>
31
+ </div>
32
+ <div className={collapsed ? 'mt-6 hidden' : 'mt-6'}>{renderMarkdownChildren(children)}</div>
33
+ </div>
34
+ )
33
35
  }
@@ -1,35 +1,40 @@
1
- import React from "react";
1
+ import React from 'react'
2
2
 
3
3
  interface TableProps {
4
- headers: string[];
5
- rows: string[][];
4
+ headers: string[]
5
+ rows: string[][]
6
6
  }
7
7
 
8
8
  export function Table({ headers, rows }: TableProps) {
9
- return (
10
- <div className="overflow-x-auto mt-3" data-md="table">
11
- <table className="w-full text-body">
12
- <thead>
13
- <tr className="border-b border-border-subtle">
14
- {headers.map((h, i) => (
15
- <th key={i} className="text-left px-4 py-2.5 text-meta font-medium uppercase tracking-wider text-text-tertiary font-body">
16
- {h}
17
- </th>
18
- ))}
19
- </tr>
20
- </thead>
21
- <tbody>
22
- {rows.map((row, ri) => (
23
- <tr key={ri} className={`relative border-b border-border-subtle last:border-b-0 transition-colors hover:bg-bg-surface/50 ${ri % 2 === 1 ? "bg-bg-surface/30" : ""}`}>
24
- {row.map((cell, ci) => (
25
- <td key={ci} className="px-4 py-2.5 text-text-secondary font-body">
26
- {cell}
27
- </td>
28
- ))}
29
- </tr>
30
- ))}
31
- </tbody>
32
- </table>
33
- </div>
34
- );
9
+ return (
10
+ <div className="overflow-x-auto mt-3" data-md="table">
11
+ <table className="w-full text-body">
12
+ <thead>
13
+ <tr className="border-b border-border-subtle">
14
+ {headers.map((h, i) => (
15
+ <th key={i} className="text-left px-4 py-2.5 text-meta font-medium uppercase tracking-wider text-text-tertiary font-body">
16
+ {h}
17
+ </th>
18
+ ))}
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ {rows.map((row, ri) => (
23
+ <tr
24
+ key={ri}
25
+ className={`relative border-b border-border-subtle last:border-b-0 transition-colors hover:bg-bg-surface/50 ${
26
+ ri % 2 === 1 ? 'bg-bg-surface/30' : ''
27
+ }`}
28
+ >
29
+ {row.map((cell, ci) => (
30
+ <td key={ci} className="px-4 py-2.5 text-text-secondary font-body">
31
+ {cell}
32
+ </td>
33
+ ))}
34
+ </tr>
35
+ ))}
36
+ </tbody>
37
+ </table>
38
+ </div>
39
+ )
35
40
  }
@@ -1,76 +1,74 @@
1
- import React from "react";
2
- import { renderMarkdownChildren } from "./renderMarkdownChildren";
1
+ import React from 'react'
2
+ import { renderMarkdownChildren } from './renderMarkdownChildren'
3
3
 
4
- type Status = "todo" | "done" | "blocked" | "in-progress";
5
- type BadgeVariant = "info" | "success" | "warning" | "danger" | "neutral";
4
+ type Status = 'todo' | 'done' | 'blocked' | 'in-progress'
5
+ type BadgeVariant = 'info' | 'success' | 'warning' | 'danger' | 'neutral'
6
6
 
7
7
  interface ItemProps {
8
- id: string;
9
- label: string;
10
- status?: Status;
11
- badge?: string;
12
- badgeVariant?: BadgeVariant;
13
- children?: React.ReactNode;
8
+ id: string
9
+ label: string
10
+ status?: Status
11
+ badge?: string
12
+ badgeVariant?: BadgeVariant
13
+ children?: React.ReactNode
14
14
  }
15
15
 
16
16
  const dotColors: Record<Status, string> = {
17
- todo: "bg-border-hover",
18
- done: "bg-accent-green",
19
- blocked: "bg-accent-red",
20
- "in-progress": "bg-accent-blue",
21
- };
17
+ todo: 'bg-border-hover',
18
+ done: 'bg-accent-green',
19
+ blocked: 'bg-accent-red',
20
+ 'in-progress': 'bg-accent-blue',
21
+ }
22
22
 
23
23
  const statusLabels: Record<Status, string> = {
24
- todo: "Todo",
25
- done: "Done",
26
- blocked: "Blocked",
27
- "in-progress": "In progress",
28
- };
24
+ todo: 'Todo',
25
+ done: 'Done',
26
+ blocked: 'Blocked',
27
+ 'in-progress': 'In progress',
28
+ }
29
29
 
30
30
  const badgeStyles: Record<BadgeVariant, string> = {
31
- info: "bg-accent-blue-muted text-accent-blue",
32
- success: "bg-accent-green-muted text-accent-green",
33
- warning: "bg-accent-amber-muted text-accent-amber",
34
- danger: "bg-accent-red-muted text-accent-red",
35
- neutral: "bg-border-subtle text-text-tertiary",
36
- };
31
+ info: 'bg-accent-blue-muted text-accent-blue',
32
+ success: 'bg-accent-green-muted text-accent-green',
33
+ warning: 'bg-accent-amber-muted text-accent-amber',
34
+ danger: 'bg-accent-red-muted text-accent-red',
35
+ neutral: 'bg-border-subtle text-text-tertiary',
36
+ }
37
37
 
38
- export function Item({ id, label, status, badge, badgeVariant = "neutral", children }: ItemProps) {
39
- return (
40
- <div
41
- className="group/task relative -mx-4 px-4 py-3 rounded-md transition-colors duration-150 hover:bg-bg-input"
42
- data-task-id={id}
43
- data-md="item"
44
- data-md-label={label}
45
- {...(status ? { "data-md-status": status } : {})}
46
- {...(badge ? { "data-md-badge": badge } : {})}
47
- >
48
- <div className="flex items-start gap-3">
49
- {status && <span className={`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${dotColors[status]}`} />}
50
- <div className="flex-1 min-w-0">
51
- <div className="flex items-baseline gap-2">
52
- <span className="font-body text-task-label font-semibold text-text-primary">{label}</span>
53
- {status && (
54
- <span className="font-body text-tiny uppercase tracking-wider text-text-tertiary opacity-0 group-hover/task:opacity-100 transition-opacity duration-150">
55
- {statusLabels[status]}
56
- </span>
57
- )}
58
- {badge && (
59
- <span className={`font-body text-tiny font-medium px-1.5 py-px rounded-full ${badgeStyles[badgeVariant]}`}>
60
- {badge}
61
- </span>
62
- )}
63
- </div>
64
- {children && (
65
- <div className="text-body text-text-secondary mt-1 leading-relaxed">{renderMarkdownChildren(children)}</div>
66
- )}
67
- </div>
68
- </div>
69
- </div>
70
- );
38
+ export function Item({ id, label, status, badge, badgeVariant = 'neutral', children }: ItemProps) {
39
+ return (
40
+ <div
41
+ className="group/task relative -mx-4 px-4 py-3 rounded-md transition-colors duration-150 hover:bg-bg-input"
42
+ data-task-id={id}
43
+ data-md="item"
44
+ data-md-label={label}
45
+ {...(status ? { 'data-md-status': status } : {})}
46
+ {...(badge ? { 'data-md-badge': badge } : {})}
47
+ >
48
+ <div className="flex items-start gap-3">
49
+ {status && <span className={`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${dotColors[status]}`} />}
50
+ <div className="flex-1 min-w-0">
51
+ <div className="flex items-baseline gap-2">
52
+ <span className="font-body text-task-label font-semibold text-text-primary">{label}</span>
53
+ {status && (
54
+ <span className="font-body text-tiny uppercase tracking-wider text-text-tertiary opacity-0 group-hover/task:opacity-100 transition-opacity duration-150">
55
+ {statusLabels[status]}
56
+ </span>
57
+ )}
58
+ {badge && (
59
+ <span className={`font-body text-tiny font-medium px-1.5 py-px rounded-full ${badgeStyles[badgeVariant]}`}>
60
+ {badge}
61
+ </span>
62
+ )}
63
+ </div>
64
+ {children && <div className="text-body text-text-secondary mt-1 leading-relaxed">{renderMarkdownChildren(children)}</div>}
65
+ </div>
66
+ </div>
67
+ </div>
68
+ )
71
69
  }
72
70
 
73
71
  /** @deprecated Use <Item> instead */
74
72
  export function Task(props: ItemProps) {
75
- return <Item {...props} />;
73
+ return <Item {...props} />
76
74
  }