@fabrika/canvas-kernel 0.1.45 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -67
- package/index.ts +20 -83
- package/package.json +69 -72
- package/src/client/AnnotationProvider.tsx +218 -255
- package/src/client/AnnotationSidebar.tsx +393 -338
- package/src/client/FileIcon.tsx +105 -66
- package/src/client/PlanRenderer.tsx +607 -551
- package/src/client/RenderErrorContext.ts +7 -7
- package/src/client/ResponsePreview.tsx +192 -173
- package/src/client/annotationDom.ts +43 -97
- package/src/client/annotationDraft.ts +106 -96
- package/src/client/appContext.tsx +40 -40
- package/src/client/components/Callout.tsx +20 -20
- package/src/client/components/Checklist.tsx +27 -29
- package/src/client/components/Choice.tsx +178 -159
- package/src/client/components/CodeBlock.tsx +27 -26
- package/src/client/components/Diff.tsx +16 -17
- package/src/client/components/FilePreview.tsx +102 -74
- package/src/client/components/Image.tsx +41 -39
- package/src/client/components/Markdown.tsx +33 -32
- package/src/client/components/Mermaid.tsx +593 -542
- package/src/client/components/Note.tsx +8 -8
- package/src/client/components/Priority.tsx +10 -12
- package/src/client/components/ResponseNote.tsx +16 -15
- package/src/client/components/Section.tsx +28 -26
- package/src/client/components/Table.tsx +33 -30
- package/src/client/components/Task.tsx +58 -60
- package/src/client/components/UserInput.tsx +169 -152
- package/src/client/components/index.ts +16 -16
- package/src/client/components/renderMarkdownChildren.tsx +86 -68
- package/src/client/diffLines.ts +51 -39
- package/src/client/generateMarkdown.ts +197 -191
- package/src/client/hostContext.tsx +39 -34
- package/src/client/index.ts +44 -125
- package/src/client/pageGlobals.ts +25 -0
- package/src/client/persistenceSchemas.ts +41 -0
- package/src/client/preact-all.ts +4 -4
- package/src/client/runtime.ts +58 -111
- package/src/client/styles.css +1 -74
- package/src/engine/compiler.ts +411 -323
- package/src/engine/file-admission.ts +25 -0
- package/src/engine/paths.ts +44 -44
- package/src/engine/session.ts +515 -626
- package/src/engine/sessionSchemas.ts +71 -0
- package/src/engine/watcher.ts +70 -60
- package/src/engine/websocket.ts +134 -132
- package/annotate.ts +0 -94
- package/daemon.ts +0 -46
- package/src/client/AnnotationDraftFooter.tsx +0 -76
- package/src/client/AnnotationEditor.tsx +0 -320
- package/src/client/AnnotationList.tsx +0 -190
- package/src/client/Popover.tsx +0 -361
- package/src/client/SessionContext.tsx +0 -3
- package/src/client/annotationContext.ts +0 -130
- package/src/client/annotationMarkdown.ts +0 -102
- package/src/client/annotationTarget.ts +0 -73
- package/src/client/blockTarget.ts +0 -127
- package/src/client/highlightRange.ts +0 -262
- package/src/client/popoverPosition.ts +0 -46
- package/src/client/regionTarget.ts +0 -180
- package/src/client/testing/dom.ts +0 -74
- package/src/client/textTarget.ts +0 -31
- package/src/client/useRegionAnnotation.tsx +0 -188
- package/src/client/useTextAnnotation.tsx +0 -194
- package/src/client/utils.ts +0 -33
- package/src/engine/channel.ts +0 -278
- package/src/engine/http-utils.ts +0 -14
- package/src/engine/lifecycle.ts +0 -302
- package/src/engine/router.ts +0 -16
- package/src/engine/waiter.ts +0 -188
package/README.md
CHANGED
|
@@ -1,73 +1,39 @@
|
|
|
1
1
|
# @fabrika/canvas-kernel
|
|
2
2
|
|
|
3
|
-
The
|
|
4
|
-
host-agnostic SDK for building annotatable, agent-driven canvases.
|
|
5
|
-
|
|
3
|
+
The canvas SDK from [Agent Canvas](https://github.com/contember/agent-canvas).
|
|
6
4
|
Ships as **TypeScript sources**, not a build artifact. It is written for Bun and
|
|
7
|
-
consumed by bundlers, so a host typechecks
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
|
16
|
-
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
from
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
Bun.serve({ fetch: handler, websocket: channel.handlers })
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
The channel knows about two socket roles keyed by an opaque topic string. The
|
|
45
|
-
frame vocabulary is the host's — the kernel never learns what a "submission" is.
|
|
46
|
-
|
|
47
|
-
## Annotation locators
|
|
48
|
-
|
|
49
|
-
An annotation points at something via an `AnnotationTarget<L>`, a strategy that
|
|
50
|
-
owns one locator shape end to end:
|
|
51
|
-
|
|
52
|
-
```ts
|
|
53
|
-
export interface AnnotationTarget<L extends object> {
|
|
54
|
-
readonly kind: string
|
|
55
|
-
parse(snippet: string): L | null
|
|
56
|
-
format(locator: L): string
|
|
57
|
-
find(locator: L, root: ParentNode): HTMLElement | null
|
|
58
|
-
restore?(locator: L, root: HTMLElement, ann: TargetAnnotation): void
|
|
59
|
-
describe?(locator: L): string
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Three ship: text ranges, document blocks, and rectangular regions of an image.
|
|
64
|
-
Creation and lookup read the same selector, so an annotation minted where the
|
|
65
|
-
lookup does not scan is not expressible.
|
|
66
|
-
|
|
67
|
-
## Versioning
|
|
68
|
-
|
|
69
|
-
Released in lockstep with the `agent-canvas` package — same repository, same
|
|
70
|
-
commit, same version number. Pin exactly.
|
|
5
|
+
consumed by bundlers, so a host typechecks it under its own flags.
|
|
6
|
+
|
|
7
|
+
Canvas-specific functionality over `@fabrika/daemon-kit` and
|
|
8
|
+
`@fabrika/annotations`:
|
|
9
|
+
|
|
10
|
+
| Entry | Responsibility |
|
|
11
|
+
| --------------------------- | -------------------------------------------------------------------------------------- |
|
|
12
|
+
| `/server` (also `.`) | JSX compilation, sessions/revisions, watcher, canvas WS protocol and paths |
|
|
13
|
+
| `/client` | Renderer, canvas draft persistence, responses, revision contexts, sidebar and feedback |
|
|
14
|
+
| `/components` | Interactive canvas component library |
|
|
15
|
+
| `/runtime` | Canvas contexts shared by compiled documents and the host |
|
|
16
|
+
| `/styles.css`, `/theme.css` | Canvas styling and theme |
|
|
17
|
+
|
|
18
|
+
## Migration from 0.1.x
|
|
19
|
+
|
|
20
|
+
- Replace `/daemon` imports with `@fabrika/daemon-kit`.
|
|
21
|
+
- Import daemon helpers previously reexported from `/server` directly from
|
|
22
|
+
`@fabrika/daemon-kit`. `createCanvasPaths` remains canvas-specific.
|
|
23
|
+
- Replace `/annotate` imports with `@fabrika/annotations`.
|
|
24
|
+
- Import annotation UI, locator strategies, marks and utilities previously
|
|
25
|
+
reexported from `/client` directly from `@fabrika/annotations`.
|
|
26
|
+
- The canvas `/client` `AnnotationProvider` and `PersistedState` still own
|
|
27
|
+
revisions, responses and feedback entries. The standalone annotations provider
|
|
28
|
+
instead takes `scope`, `loadState(scope)` and `saveState(scope, state)` and uses
|
|
29
|
+
`AnnotationState` with only annotations and a general note.
|
|
30
|
+
- Standalone annotation hosts use `AnnotationHostContext` and `AnnotationHost`,
|
|
31
|
+
without `loadCanvasModule`. Canvas hosts keep `CanvasHostContext`.
|
|
32
|
+
- Multi-bundle hosts must build and externalize `@fabrika/annotations/runtime`
|
|
33
|
+
in addition to `#canvas/runtime`, with one import-map entry for each.
|
|
34
|
+
|
|
35
|
+
The removed entries are not compatibility reexports. All packages release in
|
|
36
|
+
lockstep with exact internal dependency pins.
|
|
71
37
|
|
|
72
38
|
## License
|
|
73
39
|
|
package/index.ts
CHANGED
|
@@ -1,84 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// dragging the browser bundle along.
|
|
8
|
-
//
|
|
9
|
-
// The browser-facing surface (components + annotation runtime) is exposed
|
|
10
|
-
// separately through the package `imports`/`exports` maps as `#canvas/components`
|
|
11
|
-
// and `#canvas/runtime`.
|
|
12
|
-
|
|
13
|
-
// --- Compile pipeline (JSX -> Bun.build) -----------------------------------
|
|
14
|
-
export { compileJsx, compilePlan, KERNEL_COMPONENTS } from "./src/engine/compiler";
|
|
1
|
+
export { compileJsx, compilePlan, KERNEL_COMPONENTS } from './src/engine/compiler'
|
|
2
|
+
export type { CanvasComponents, CanvasComponentSpec, CompileOptions, CompileResult } from './src/engine/compiler'
|
|
3
|
+
export type { AssertReadable } from './src/engine/file-admission'
|
|
4
|
+
export { createCanvasPaths } from './src/engine/paths'
|
|
5
|
+
export type { CanvasPaths, CanvasPathsConfig } from './src/engine/paths'
|
|
6
|
+
export { SessionManager } from './src/engine/session'
|
|
15
7
|
export type {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
SecretResolution,
|
|
31
|
-
RemoteFeedbackEntry,
|
|
32
|
-
RemoteAnnotation,
|
|
33
|
-
ShareEntry,
|
|
34
|
-
} from "./src/engine/session";
|
|
35
|
-
|
|
36
|
-
// --- WebSocket notification channel (host-agnostic) ------------------------
|
|
37
|
-
export { createNotificationChannel, browserFrame } from "./src/engine/channel";
|
|
38
|
-
export type {
|
|
39
|
-
ChannelRole,
|
|
40
|
-
ChannelSocket,
|
|
41
|
-
TopicChannel,
|
|
42
|
-
RelayOptions,
|
|
43
|
-
BrowserFrameHandler,
|
|
44
|
-
NotificationChannel,
|
|
45
|
-
NotificationChannelOptions,
|
|
46
|
-
} from "./src/engine/channel";
|
|
47
|
-
|
|
48
|
-
// --- WebSocket feedback protocol (canvas vocabulary) -----------------------
|
|
49
|
-
export { createWebSocketManager } from "./src/engine/websocket";
|
|
50
|
-
export type { WSData, CanvasSocket, WebSocketManagerOptions } from "./src/engine/websocket";
|
|
51
|
-
|
|
52
|
-
// --- CLI waiter ------------------------------------------------------------
|
|
53
|
-
export { waitForEvent, WaitError } from "./src/engine/waiter";
|
|
54
|
-
export type { WaiterSocket, WaitVerdict, WaitOptions, WaitMessages, WaitFailure } from "./src/engine/waiter";
|
|
55
|
-
|
|
56
|
-
// --- Daemon process lifecycle ----------------------------------------------
|
|
57
|
-
export { createDaemonLifecycle, DaemonStartError } from "./src/engine/lifecycle";
|
|
58
|
-
export type {
|
|
59
|
-
DaemonLifecycle,
|
|
60
|
-
DaemonLifecycleConfig,
|
|
61
|
-
DaemonHealth,
|
|
62
|
-
DaemonHealthUp,
|
|
63
|
-
DaemonHealthDown,
|
|
64
|
-
DaemonPid,
|
|
65
|
-
DaemonStopResult,
|
|
66
|
-
DaemonStopReason,
|
|
67
|
-
DaemonEvent,
|
|
68
|
-
DaemonTimeouts,
|
|
69
|
-
} from "./src/engine/lifecycle";
|
|
70
|
-
|
|
71
|
-
// --- JSX watcher -----------------------------------------------------------
|
|
72
|
-
export { watchSession, unwatchSession, unwatchAll } from "./src/engine/watcher";
|
|
73
|
-
export type { WatchOptions } from "./src/engine/watcher";
|
|
74
|
-
|
|
75
|
-
// --- Router ----------------------------------------------------------------
|
|
76
|
-
export { dispatch } from "./src/engine/router";
|
|
77
|
-
export type { Route, RouteHandler } from "./src/engine/router";
|
|
78
|
-
|
|
79
|
-
// --- HTTP helpers ----------------------------------------------------------
|
|
80
|
-
export { jsonResponse, corsHeaders } from "./src/engine/http-utils";
|
|
81
|
-
|
|
82
|
-
// --- On-disk layout --------------------------------------------------------
|
|
83
|
-
export { createCanvasPaths } from "./src/engine/paths";
|
|
84
|
-
export type { CanvasPaths, CanvasPathsConfig } from "./src/engine/paths";
|
|
8
|
+
CanvasFileInfo,
|
|
9
|
+
CanvasScope,
|
|
10
|
+
DiffStats,
|
|
11
|
+
RemoteAnnotation,
|
|
12
|
+
RemoteFeedbackEntry,
|
|
13
|
+
RevisionInfo,
|
|
14
|
+
SecretResolution,
|
|
15
|
+
SessionData,
|
|
16
|
+
ShareEntry,
|
|
17
|
+
} from './src/engine/session'
|
|
18
|
+
export { unwatchAll, unwatchSession, watchSession } from './src/engine/watcher'
|
|
19
|
+
export type { WatchOptions } from './src/engine/watcher'
|
|
20
|
+
export { createWebSocketManager } from './src/engine/websocket'
|
|
21
|
+
export type { CanvasSocket, WebSocketManagerOptions, WSData } from './src/engine/websocket'
|
package/package.json
CHANGED
|
@@ -1,74 +1,71 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"@types/react-dom": "^18.3.1",
|
|
72
|
-
"happy-dom": "^20.11.2"
|
|
73
|
-
}
|
|
2
|
+
"name": "@fabrika/canvas-kernel",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Canvas JSX compiler, session/revision store, renderer and interactive component library.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/contember/fabrika-platform.git",
|
|
10
|
+
"directory": "packages/canvas-kernel"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"index.ts",
|
|
17
|
+
"src",
|
|
18
|
+
"!src/**/*.test.ts",
|
|
19
|
+
"!src/**/*.test.tsx"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"bun": "./index.ts",
|
|
24
|
+
"types": "./index.ts",
|
|
25
|
+
"default": "./index.ts"
|
|
26
|
+
},
|
|
27
|
+
"./server": {
|
|
28
|
+
"bun": "./index.ts",
|
|
29
|
+
"types": "./index.ts",
|
|
30
|
+
"default": "./index.ts"
|
|
31
|
+
},
|
|
32
|
+
"./client": {
|
|
33
|
+
"bun": "./src/client/index.ts",
|
|
34
|
+
"types": "./src/client/index.ts",
|
|
35
|
+
"default": "./src/client/index.ts"
|
|
36
|
+
},
|
|
37
|
+
"./components": {
|
|
38
|
+
"bun": "./src/client/components/index.ts",
|
|
39
|
+
"types": "./src/client/components/index.ts",
|
|
40
|
+
"default": "./src/client/components/index.ts"
|
|
41
|
+
},
|
|
42
|
+
"./runtime": {
|
|
43
|
+
"bun": "./src/client/runtime.ts",
|
|
44
|
+
"types": "./src/client/runtime.ts",
|
|
45
|
+
"default": "./src/client/runtime.ts"
|
|
46
|
+
},
|
|
47
|
+
"./styles.css": "./src/client/styles.css",
|
|
48
|
+
"./theme.css": "./src/client/theme.css"
|
|
49
|
+
},
|
|
50
|
+
"imports": {
|
|
51
|
+
"#canvas/components": "./src/client/components/index.ts",
|
|
52
|
+
"#canvas/runtime": "./src/client/runtime.ts"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"test": "bun test"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"zod": "^3.25.76",
|
|
60
|
+
"@fabrika/annotations": "^0.3.1",
|
|
61
|
+
"@fabrika/daemon-kit": "^0.3.1",
|
|
62
|
+
"marked": "^17.0.4",
|
|
63
|
+
"mermaid-parser-bundle": "^0.1.2",
|
|
64
|
+
"preact": "^10.25.0",
|
|
65
|
+
"preact-render-to-string": "^6.6.6"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"react": ">=18",
|
|
69
|
+
"react-dom": ">=18"
|
|
70
|
+
}
|
|
74
71
|
}
|