@neta-art/cohub 5.9.0 → 6.0.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 (55) hide show
  1. package/README.md +42 -46
  2. package/dist/board/animation.d.ts +156 -67
  3. package/dist/board/animation.js +162 -277
  4. package/dist/board/codec.js +1 -1
  5. package/dist/board/export/index.d.ts +6 -0
  6. package/dist/board/export/index.js +6 -3
  7. package/dist/board/export/scene.d.ts +6 -0
  8. package/dist/board/export/scene.js +26 -2
  9. package/dist/board/geometry.d.ts +27 -1
  10. package/dist/board/geometry.js +92 -1
  11. package/dist/board/headless/index.d.ts +7 -1
  12. package/dist/board/headless/index.js +6 -2
  13. package/dist/board/index.d.ts +8 -6
  14. package/dist/board/index.js +7 -6
  15. package/dist/board/mutation.d.ts +15 -0
  16. package/dist/board/mutation.js +67 -0
  17. package/dist/board/render/css-color.d.ts +4 -0
  18. package/dist/board/render/css-color.js +36 -0
  19. package/dist/board/render/index.d.ts +2 -1
  20. package/dist/board/render/index.js +2 -1
  21. package/dist/board/render/renderers/base-card-renderer.js +3 -20
  22. package/dist/board/render/themes/clean-theme.js +6 -3
  23. package/dist/chunks/http.d.ts +30 -7
  24. package/dist/chunks/http.js +785 -289
  25. package/dist/chunks/websocket.d.ts +2675 -187
  26. package/dist/http.d.ts +3 -3
  27. package/dist/index.d.ts +158 -299
  28. package/dist/index.js +164 -279
  29. package/dist/protocol/dist/board-authoring.d.ts +1 -0
  30. package/dist/protocol/dist/board-authoring.js +217 -0
  31. package/dist/protocol/dist/board-capability-registry.d.ts +2 -0
  32. package/dist/protocol/dist/board-capability-registry.js +74 -0
  33. package/dist/protocol/dist/board-codec.d.ts +2 -0
  34. package/dist/protocol/dist/board-codec.js +4 -0
  35. package/dist/protocol/dist/board-composition.d.ts +258 -0
  36. package/dist/protocol/dist/board-composition.js +318 -0
  37. package/dist/protocol/dist/board-constants.d.ts +2 -1
  38. package/dist/protocol/dist/board-constants.js +40 -10
  39. package/dist/protocol/dist/board-document.d.ts +28 -2
  40. package/dist/protocol/dist/board-document.js +16 -3
  41. package/dist/protocol/dist/board-node.d.ts +1 -11
  42. package/dist/protocol/dist/board-node.js +1 -81
  43. package/dist/protocol/dist/board-upgrade.d.ts +1 -0
  44. package/dist/protocol/dist/board-upgrade.js +2 -0
  45. package/dist/protocol/dist/board-url.d.ts +2 -1
  46. package/dist/protocol/dist/board-url.js +8 -3
  47. package/dist/protocol/dist/board.d.ts +135 -76
  48. package/dist/protocol/dist/board.js +50 -69
  49. package/dist/protocol/dist/index.d.ts +9 -4
  50. package/dist/protocol/dist/index.js +9 -4
  51. package/dist/types.d.ts +3 -2
  52. package/docs/work-runtime-guide.md +19 -3
  53. package/package.json +3 -2
  54. package/dist/board/nodes.d.ts +0 -113
  55. package/dist/board/nodes.js +0 -154
@@ -1,113 +0,0 @@
1
- import { BoardColorId, BoardGeoKind, BoardNodeValidationDiagnostic } from "../protocol/dist/board-node.js";
2
- import { BoardNodeInput } from "../protocol/dist/board.js";
3
- import "../protocol/dist/index.js";
4
- import { BoardAudioItem, BoardFileSnapshot, BoardMediaSnapshot, BoardTaskSnapshot } from "../protocol/dist/board-document.js";
5
- //#region src/board/nodes.d.ts
6
- type BoardNodeFrameInput = {
7
- x: number;
8
- y: number;
9
- width: number;
10
- height: number;
11
- rotation?: number;
12
- };
13
- type BoardNodeSpecBase = {
14
- id: string;
15
- parentId?: string | null;
16
- orderKey?: string | null;
17
- style?: Record<string, unknown>;
18
- };
19
- type BoardBoxNodeSpec = BoardNodeSpecBase & {
20
- frame: BoardNodeFrameInput;
21
- };
22
- type BoardMediaNodeSpec = BoardBoxNodeSpec & {
23
- path: string;
24
- snapshot?: BoardMediaSnapshot;
25
- };
26
- type BoardNodeSpec = (BoardBoxNodeSpec & {
27
- type: "text";
28
- text?: string;
29
- color?: BoardColorId;
30
- fontSize?: number;
31
- }) | (BoardBoxNodeSpec & {
32
- type: "geo";
33
- geo?: BoardGeoKind;
34
- text?: string;
35
- color?: BoardColorId;
36
- fillOpacity?: number;
37
- }) | (BoardNodeSpecBase & {
38
- type: "draw";
39
- /** Raw world-space samples. Stored points are converted to frame-local space. */
40
- points: Array<{
41
- x: number;
42
- y: number;
43
- p?: number;
44
- }>;
45
- color?: BoardColorId;
46
- size?: number;
47
- }) | (BoardNodeSpecBase & {
48
- type: "arrow";
49
- start: {
50
- x: number;
51
- y: number;
52
- };
53
- end: {
54
- x: number;
55
- y: number;
56
- };
57
- bend?: number;
58
- color?: BoardColorId;
59
- size?: number;
60
- arrowStart?: boolean;
61
- arrowEnd?: boolean;
62
- label?: string;
63
- }) | (BoardBoxNodeSpec & {
64
- type: "frame";
65
- label?: string;
66
- color?: BoardColorId;
67
- }) | (BoardMediaNodeSpec & {
68
- type: "image";
69
- crop?: {
70
- x: number;
71
- y: number;
72
- w: number;
73
- h: number;
74
- };
75
- }) | (BoardMediaNodeSpec & {
76
- type: "video";
77
- }) | (Omit<BoardMediaNodeSpec, "snapshot"> & {
78
- type: "audio";
79
- snapshot?: BoardAudioItem["snapshot"];
80
- }) | (BoardBoxNodeSpec & {
81
- type: "file";
82
- path: string;
83
- snapshot?: BoardFileSnapshot;
84
- }) | (BoardBoxNodeSpec & {
85
- type: "task";
86
- taskRunId: string;
87
- snapshot: BoardTaskSnapshot;
88
- });
89
- declare class BoardInputError extends Error {
90
- readonly code = "INVALID_BOARD_NODE";
91
- readonly diagnostics: BoardNodeValidationDiagnostic[];
92
- readonly body: {
93
- code: "INVALID_BOARD_NODE";
94
- message: string;
95
- diagnostics: BoardNodeValidationDiagnostic[];
96
- };
97
- constructor(diagnostics: BoardNodeValidationDiagnostic[]);
98
- }
99
- /**
100
- * Create one validated wire node from semantic Board input.
101
- *
102
- * Box nodes take an explicit world-space frame. Draw samples and arrow endpoints
103
- * take world coordinates; the builder derives their frame and local storage form.
104
- */
105
- declare function createBoardNode(spec: BoardNodeSpec): BoardNodeInput;
106
- declare function validateBoardNodes(nodes: readonly BoardNodeInput[], path?: string): BoardNodeValidationDiagnostic[];
107
- declare function assertBoardNodes(nodes: readonly BoardNodeInput[], path?: string): void;
108
- declare function assertBoardTransactionNodeCreates(operations: ReadonlyArray<{
109
- type: string;
110
- payload: unknown;
111
- }>): void;
112
- //#endregion
113
- export { BoardInputError, BoardNodeFrameInput, BoardNodeSpec, assertBoardNodes, assertBoardTransactionNodeCreates, createBoardNode, validateBoardNodes };
@@ -1,154 +0,0 @@
1
- import "../protocol/dist/board-constants.js";
2
- import { validateBoardNodeInput } from "../protocol/dist/board-node.js";
3
- import "../protocol/dist/index.js";
4
- import { computeDrawBounds } from "./core/draw-geometry.js";
5
- //#region src/board/nodes.ts
6
- var BoardInputError = class extends Error {
7
- code = "INVALID_BOARD_NODE";
8
- diagnostics;
9
- body;
10
- constructor(diagnostics) {
11
- const message = diagnostics[0]?.message ?? "Invalid Board node";
12
- super(message);
13
- this.name = "BoardInputError";
14
- this.diagnostics = diagnostics;
15
- this.body = {
16
- code: this.code,
17
- message,
18
- diagnostics
19
- };
20
- }
21
- };
22
- function baseNode(spec, frame) {
23
- return {
24
- nodeId: spec.id,
25
- type: spec.type,
26
- parentId: spec.parentId ?? null,
27
- orderKey: spec.orderKey ?? null,
28
- x: frame.x,
29
- y: frame.y,
30
- width: frame.width,
31
- height: frame.height,
32
- rotation: frame.rotation ?? 0,
33
- refKind: null,
34
- refPath: null,
35
- refUrl: null,
36
- view: {},
37
- style: spec.style ?? {},
38
- data: {}
39
- };
40
- }
41
- function arrowFrame(start, end) {
42
- const padding = 16;
43
- return {
44
- x: Math.min(start.x, end.x) - padding,
45
- y: Math.min(start.y, end.y) - padding,
46
- width: Math.max(1, Math.abs(end.x - start.x) + padding * 2),
47
- height: Math.max(1, Math.abs(end.y - start.y) + padding * 2)
48
- };
49
- }
50
- /**
51
- * Create one validated wire node from semantic Board input.
52
- *
53
- * Box nodes take an explicit world-space frame. Draw samples and arrow endpoints
54
- * take world coordinates; the builder derives their frame and local storage form.
55
- */
56
- function createBoardNode(spec) {
57
- let node;
58
- if (spec.type === "draw") {
59
- const size = spec.size ?? 4;
60
- const worldPoints = spec.points.map((point) => ({
61
- x: point.x,
62
- y: point.y,
63
- p: point.p ?? .5
64
- }));
65
- const bounds = computeDrawBounds(worldPoints, size);
66
- node = baseNode(spec, bounds);
67
- node.data = {
68
- points: worldPoints.map((point) => ({
69
- x: point.x - bounds.x,
70
- y: point.y - bounds.y,
71
- p: point.p
72
- })),
73
- color: spec.color ?? "brand",
74
- size
75
- };
76
- } else if (spec.type === "arrow") {
77
- node = baseNode(spec, arrowFrame(spec.start, spec.end));
78
- node.data = {
79
- start: spec.start,
80
- end: spec.end,
81
- bend: spec.bend ?? 0,
82
- color: spec.color ?? "brand",
83
- size: spec.size ?? 2.5,
84
- arrowStart: spec.arrowStart ?? false,
85
- arrowEnd: spec.arrowEnd ?? true,
86
- label: spec.label ?? ""
87
- };
88
- } else {
89
- node = baseNode(spec, spec.frame);
90
- switch (spec.type) {
91
- case "text":
92
- node.data = {
93
- text: spec.text ?? "",
94
- color: spec.color ?? "neutral",
95
- fontSize: spec.fontSize ?? 24
96
- };
97
- break;
98
- case "geo":
99
- node.data = {
100
- geo: spec.geo ?? "rectangle",
101
- text: spec.text ?? "",
102
- color: spec.color ?? "brand",
103
- fillOpacity: spec.fillOpacity ?? 0
104
- };
105
- break;
106
- case "frame":
107
- node.data = {
108
- label: spec.label ?? "Frame",
109
- color: spec.color ?? "neutral"
110
- };
111
- break;
112
- case "image":
113
- node.refKind = "space_file";
114
- node.refPath = spec.path;
115
- node.view = spec.snapshot ?? {};
116
- node.data = spec.crop ? { crop: spec.crop } : {};
117
- break;
118
- case "video":
119
- case "audio":
120
- node.refKind = "space_file";
121
- node.refPath = spec.path;
122
- node.view = spec.snapshot ?? {};
123
- break;
124
- case "file":
125
- node.refKind = "space_file";
126
- node.refPath = spec.path;
127
- node.view = spec.snapshot ?? {};
128
- break;
129
- case "task":
130
- node.view = spec.snapshot;
131
- node.data = { taskRunId: spec.taskRunId };
132
- break;
133
- }
134
- }
135
- assertBoardNodes([node]);
136
- return node;
137
- }
138
- function validateBoardNodes(nodes, path = "nodes") {
139
- return nodes.flatMap((node, index) => validateBoardNodeInput(node, `${path}.${index}`));
140
- }
141
- function assertBoardNodes(nodes, path = "nodes") {
142
- const diagnostics = validateBoardNodes(nodes, path);
143
- if (diagnostics.length > 0) throw new BoardInputError(diagnostics);
144
- }
145
- function assertBoardTransactionNodeCreates(operations) {
146
- const diagnostics = operations.flatMap((operation, index) => {
147
- if (operation.type !== "node.create") return [];
148
- const payload = operation.payload;
149
- return payload.node ? validateBoardNodeInput(payload.node, `operations.${index}.payload.node`) : [];
150
- });
151
- if (diagnostics.length > 0) throw new BoardInputError(diagnostics);
152
- }
153
- //#endregion
154
- export { BoardInputError, assertBoardNodes, assertBoardTransactionNodeCreates, createBoardNode, validateBoardNodes };