@neta-art/cohub 5.10.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.
- package/README.md +42 -46
- package/dist/board/animation.d.ts +156 -67
- package/dist/board/animation.js +161 -305
- package/dist/board/geometry.js +4 -4
- package/dist/board/index.d.ts +4 -4
- package/dist/board/index.js +3 -4
- package/dist/board/mutation.d.ts +5 -11
- package/dist/board/mutation.js +9 -46
- package/dist/chunks/http.d.ts +23 -12
- package/dist/chunks/http.js +674 -316
- package/dist/chunks/websocket.d.ts +2623 -201
- package/dist/http.d.ts +3 -3
- package/dist/index.d.ts +158 -299
- package/dist/index.js +164 -306
- package/dist/protocol/dist/board-authoring.d.ts +1 -0
- package/dist/protocol/dist/board-authoring.js +217 -0
- package/dist/protocol/dist/board-capability-registry.d.ts +2 -0
- package/dist/protocol/dist/board-capability-registry.js +74 -0
- package/dist/protocol/dist/board-codec.d.ts +2 -0
- package/dist/protocol/dist/board-codec.js +4 -0
- package/dist/protocol/dist/board-composition.d.ts +258 -0
- package/dist/protocol/dist/board-composition.js +318 -0
- package/dist/protocol/dist/board-constants.js +0 -25
- package/dist/protocol/dist/board-node.d.ts +1 -12
- package/dist/protocol/dist/board-node.js +1 -81
- package/dist/protocol/dist/board-upgrade.d.ts +1 -0
- package/dist/protocol/dist/board-upgrade.js +2 -0
- package/dist/protocol/dist/board.d.ts +19 -92
- package/dist/protocol/dist/board.js +18 -78
- package/dist/protocol/dist/index.d.ts +8 -3
- package/dist/protocol/dist/index.js +9 -4
- package/dist/types.d.ts +2 -1
- package/docs/work-runtime-guide.md +19 -3
- package/package.json +3 -2
- package/dist/board/nodes.d.ts +0 -113
- package/dist/board/nodes.js +0 -154
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import "./board-constants.js";
|
|
1
|
+
import { BOARD_BUILTIN_CAPABILITIES, DEFAULT_BOARD_RENDER_LIMITS } from "./board-constants.js";
|
|
2
2
|
import { BoardConnectionSchema } from "./board-connection.js";
|
|
3
|
+
import { BoardCompositionInputSchema } from "./board-composition.js";
|
|
4
|
+
import { BoardAuthoringItemSchema } from "./board-authoring.js";
|
|
3
5
|
import { z } from "zod";
|
|
4
6
|
//#region ../protocol/dist/board.js
|
|
5
7
|
const BOARD_EXTENSION = ".board";
|
|
@@ -36,18 +38,6 @@ function parseBoardManifest(input) {
|
|
|
36
38
|
function serializeBoardManifest(manifest) {
|
|
37
39
|
return `${JSON.stringify(BoardManifestSchema.parse(manifest), null, 2)}\n`;
|
|
38
40
|
}
|
|
39
|
-
const BoardTargetSchema = z.discriminatedUnion("type", [
|
|
40
|
-
z.object({
|
|
41
|
-
type: z.literal("node"),
|
|
42
|
-
nodeId: idSchema
|
|
43
|
-
}),
|
|
44
|
-
z.object({
|
|
45
|
-
type: z.literal("effect"),
|
|
46
|
-
effectId: idSchema
|
|
47
|
-
}),
|
|
48
|
-
z.object({ type: z.literal("board") }),
|
|
49
|
-
z.object({ type: z.literal("camera") })
|
|
50
|
-
]);
|
|
51
41
|
const BoardCameraStateSchema = z.object({
|
|
52
42
|
centerX: finiteSchema,
|
|
53
43
|
centerY: finiteSchema,
|
|
@@ -64,12 +54,12 @@ const BoardCameraFocusSchema = z.discriminatedUnion("type", [
|
|
|
64
54
|
})
|
|
65
55
|
}),
|
|
66
56
|
z.object({
|
|
67
|
-
type: z.literal("
|
|
68
|
-
|
|
57
|
+
type: z.literal("item"),
|
|
58
|
+
itemId: idSchema
|
|
69
59
|
}),
|
|
70
60
|
z.object({
|
|
71
|
-
type: z.literal("
|
|
72
|
-
|
|
61
|
+
type: z.literal("items"),
|
|
62
|
+
itemIds: z.array(idSchema).min(1).max(1e3)
|
|
73
63
|
}),
|
|
74
64
|
z.object({
|
|
75
65
|
type: z.literal("frame"),
|
|
@@ -94,45 +84,13 @@ const BoardAssetRefSchema = z.object({
|
|
|
94
84
|
ref: z.string().min(1).max(4096),
|
|
95
85
|
digest: z.string().min(16).max(160).optional()
|
|
96
86
|
});
|
|
97
|
-
const BoardKeyframeSchema = z.object({
|
|
98
|
-
at: finiteSchema.nonnegative(),
|
|
99
|
-
value: z.unknown(),
|
|
100
|
-
easing: z.string().min(1).max(80).optional()
|
|
101
|
-
});
|
|
102
|
-
const BoardClipSchema = z.object({
|
|
103
|
-
id: idSchema,
|
|
104
|
-
sequenceId: idSchema,
|
|
105
|
-
kind: extensionIdSchema,
|
|
106
|
-
kindVersion: z.number().int().positive(),
|
|
107
|
-
target: BoardTargetSchema,
|
|
108
|
-
start: finiteSchema.nonnegative(),
|
|
109
|
-
duration: finiteSchema.positive(),
|
|
110
|
-
layer: z.enum([
|
|
111
|
-
"behind",
|
|
112
|
-
"content",
|
|
113
|
-
"front",
|
|
114
|
-
"screen"
|
|
115
|
-
]).default("content"),
|
|
116
|
-
fill: z.enum([
|
|
117
|
-
"none",
|
|
118
|
-
"backwards",
|
|
119
|
-
"forwards",
|
|
120
|
-
"both"
|
|
121
|
-
]).default("none"),
|
|
122
|
-
easing: z.string().min(1).max(80).default("linear"),
|
|
123
|
-
params: jsonObjectSchema.default({}),
|
|
124
|
-
keyframes: z.array(BoardKeyframeSchema).default([]),
|
|
125
|
-
assetRefs: z.array(BoardAssetRefSchema).default([]),
|
|
126
|
-
seed: z.string().min(1).max(160),
|
|
127
|
-
metadata: jsonObjectSchema.default({})
|
|
128
|
-
});
|
|
129
87
|
const BoardEffectSchema = z.object({
|
|
130
88
|
id: idSchema,
|
|
131
89
|
boardId: z.string().uuid(),
|
|
132
90
|
target: z.discriminatedUnion("type", [z.object({
|
|
133
|
-
type: z.literal("
|
|
134
|
-
|
|
135
|
-
}), z.object({ type: z.literal("board") })]),
|
|
91
|
+
type: z.literal("item"),
|
|
92
|
+
itemId: idSchema
|
|
93
|
+
}).strict(), z.object({ type: z.literal("board") }).strict()]),
|
|
136
94
|
kind: extensionIdSchema,
|
|
137
95
|
kindVersion: z.number().int().positive(),
|
|
138
96
|
enabled: z.boolean().default(true),
|
|
@@ -157,17 +115,7 @@ const BoardEffectSchema = z.object({
|
|
|
157
115
|
metadata: jsonObjectSchema.default({}),
|
|
158
116
|
revision: z.number().int().nonnegative()
|
|
159
117
|
});
|
|
160
|
-
|
|
161
|
-
id: idSchema,
|
|
162
|
-
boardId: z.string().uuid(),
|
|
163
|
-
name: z.string().min(1).max(255),
|
|
164
|
-
duration: finiteSchema.nonnegative(),
|
|
165
|
-
seed: z.string().min(1).max(160),
|
|
166
|
-
restPose: jsonObjectSchema.default({}),
|
|
167
|
-
metadata: jsonObjectSchema.default({}),
|
|
168
|
-
revision: z.number().int().nonnegative()
|
|
169
|
-
});
|
|
170
|
-
const BoardNodeInputSchema = z.object({
|
|
118
|
+
z.object({
|
|
171
119
|
nodeId: idSchema,
|
|
172
120
|
type: z.string().min(1).max(40),
|
|
173
121
|
parentId: idSchema.nullable(),
|
|
@@ -190,27 +138,20 @@ z.object({
|
|
|
190
138
|
mutationId: z.string().max(128).optional(),
|
|
191
139
|
title: z.string().min(1).max(255).optional(),
|
|
192
140
|
metadata: jsonObjectSchema.optional(),
|
|
193
|
-
|
|
141
|
+
items: z.array(BoardAuthoringItemSchema).max(5e4).optional(),
|
|
194
142
|
connections: z.array(BoardConnectionSchema).max(5e4).optional(),
|
|
195
143
|
effects: z.array(BoardEffectSchema.omit({
|
|
196
144
|
boardId: true,
|
|
197
145
|
revision: true
|
|
198
146
|
})).optional(),
|
|
199
|
-
|
|
200
|
-
sequence: BoardSequenceSchema.omit({
|
|
201
|
-
boardId: true,
|
|
202
|
-
revision: true
|
|
203
|
-
}),
|
|
204
|
-
clips: z.array(BoardClipSchema.omit({ sequenceId: true }))
|
|
205
|
-
})).optional()
|
|
147
|
+
compositions: z.array(BoardCompositionInputSchema).optional()
|
|
206
148
|
});
|
|
207
149
|
z.object({
|
|
208
150
|
include: z.array(z.enum([
|
|
209
151
|
"nodes",
|
|
210
152
|
"connections",
|
|
211
153
|
"effects",
|
|
212
|
-
"
|
|
213
|
-
"clips",
|
|
154
|
+
"compositions",
|
|
214
155
|
"playback"
|
|
215
156
|
])).optional(),
|
|
216
157
|
viewport: z.object({
|
|
@@ -221,16 +162,15 @@ z.object({
|
|
|
221
162
|
}).optional()
|
|
222
163
|
});
|
|
223
164
|
z.object({
|
|
224
|
-
|
|
165
|
+
compositionId: idSchema,
|
|
225
166
|
/** Delay before the first local playback after opening the Board, in milliseconds. */
|
|
226
|
-
delayMs: finiteSchema.nonnegative().default(0)
|
|
227
|
-
loop: z.boolean().default(false)
|
|
167
|
+
delayMs: finiteSchema.nonnegative().default(0)
|
|
228
168
|
});
|
|
229
169
|
z.discriminatedUnion("type", [
|
|
230
170
|
z.object({
|
|
231
171
|
commandId: idSchema,
|
|
232
172
|
type: z.literal("play"),
|
|
233
|
-
|
|
173
|
+
compositionId: idSchema,
|
|
234
174
|
position: finiteSchema.nonnegative().optional(),
|
|
235
175
|
timeScale: finiteSchema.positive().max(4).optional(),
|
|
236
176
|
shared: z.boolean().optional(),
|
|
@@ -257,4 +197,4 @@ function isBoardPath(path) {
|
|
|
257
197
|
return path.toLowerCase().endsWith(BOARD_EXTENSION);
|
|
258
198
|
}
|
|
259
199
|
//#endregion
|
|
260
|
-
export { BOARD_DOCUMENT_KIND, BOARD_EXTENSION, BOARD_MANIFEST_KIND, BoardAssetRefSchema, BoardCameraFocusParamsSchema, BoardCameraFocusSchema, BoardCameraStateSchema,
|
|
200
|
+
export { BOARD_BUILTIN_CAPABILITIES, BOARD_DOCUMENT_KIND, BOARD_EXTENSION, BOARD_MANIFEST_KIND, BoardAssetRefSchema, BoardCameraFocusParamsSchema, BoardCameraFocusSchema, BoardCameraStateSchema, BoardEffectSchema, BoardManifestSchema, DEFAULT_BOARD_RENDER_LIMITS, InvalidBoardFileError, isBoardPath, parseBoardManifest, serializeBoardManifest };
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { BoardCapability, BoardCoordinateSpace, BoardRenderCost } from "./board-constants.js";
|
|
2
2
|
import { AUTO_BOARD_CONNECTION_ANCHOR, BOARD_CONNECTION_DIRECTIONS, BOARD_CONNECTION_LINES, BOARD_CONNECTION_ROUTINGS, BOARD_CONNECTION_SIDES, BoardConnection, BoardConnectionAnchor, BoardConnectionAnchorSchema, BoardConnectionDirection, BoardConnectionEndpoint, BoardConnectionEndpointSchema, BoardConnectionInput, BoardConnectionLine, BoardConnectionPatch, BoardConnectionPatchSchema, BoardConnectionRecord, BoardConnectionRouting, BoardConnectionRoutingConfig, BoardConnectionRoutingSchema, BoardConnectionSchema, BoardConnectionSide, BoardConnectionStyle, BoardConnectionStyleSchema, BoardConnectionWaypointSchema, BoardRelationSchema, DEFAULT_BOARD_CONNECTION_ROUTING, DEFAULT_BOARD_CONNECTION_STYLE, DEFAULT_BOARD_RELATION, connectionNodeIds, connectionOtherNodeId, connectionTouchesNode, createBoardConnection, flipBoardConnection, normalizeBoardConnectionStyle } from "./board-connection.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { BoardAnimationTarget, BoardAnimationTargetSchema, BoardComposition, BoardCompositionSchema, BoardEasing, BoardEasingSchema, BoardProceduralClip, BoardProceduralClipSchema, BoardTimelineMarker, BoardTimelineMarkerSchema, BoardTrack, BoardTrackInterpolation, BoardTrackSchema } from "./board-composition.js";
|
|
4
|
+
import { BOARD_COLOR_IDS, BOARD_GEO_KINDS, BoardColorId, BoardGeoKind } from "./board-node.js";
|
|
5
|
+
import { BOARD_DELETE_REASONS, BOARD_DOCUMENT_KIND, BOARD_EXTENSION, BoardAssetRef, BoardAssetRefSchema, BoardCameraFocus, BoardCameraFocusParams, BoardCameraFocusParamsSchema, BoardCameraFocusSchema, BoardCameraState, BoardCameraStateSchema, BoardDeleteReason, BoardDiagnostic, BoardEffect, BoardEffectSchema, BoardManifest, BoardManifestSchema, BoardNodeInput, BoardNodeRecord, BoardOperation, BoardPlaybackPolicy, BoardPlaybackPolicySchema, BoardRecord, BoardValidationResult, InvalidBoardFileError, isBoardPath, parseBoardManifest, serializeBoardManifest } from "./board.js";
|
|
6
|
+
import "./board-authoring.js";
|
|
7
|
+
import "./board-capability-registry.js";
|
|
8
|
+
import "./board-codec.js";
|
|
5
9
|
import "./board-content.js";
|
|
10
|
+
import "./board-upgrade.js";
|
|
6
11
|
import "./realtime/board-awareness.js";
|
|
7
12
|
import "./work.js";
|
|
8
13
|
import "./realtime/types.js";
|
|
9
|
-
export { AUTO_BOARD_CONNECTION_ANCHOR, BOARD_COLOR_IDS, BOARD_CONNECTION_DIRECTIONS, BOARD_CONNECTION_LINES, BOARD_CONNECTION_ROUTINGS, BOARD_CONNECTION_SIDES, BOARD_DELETE_REASONS, BOARD_DOCUMENT_KIND, BOARD_EXTENSION, BOARD_GEO_KINDS, BoardAssetRef, BoardAssetRefSchema, BoardCameraFocus, BoardCameraFocusParams, BoardCameraFocusParamsSchema, BoardCameraFocusSchema, BoardCameraState, BoardCameraStateSchema,
|
|
14
|
+
export { AUTO_BOARD_CONNECTION_ANCHOR, BOARD_COLOR_IDS, BOARD_CONNECTION_DIRECTIONS, BOARD_CONNECTION_LINES, BOARD_CONNECTION_ROUTINGS, BOARD_CONNECTION_SIDES, BOARD_DELETE_REASONS, BOARD_DOCUMENT_KIND, BOARD_EXTENSION, BOARD_GEO_KINDS, BoardAnimationTarget, BoardAnimationTargetSchema, BoardAssetRef, BoardAssetRefSchema, BoardCameraFocus, BoardCameraFocusParams, BoardCameraFocusParamsSchema, BoardCameraFocusSchema, BoardCameraState, BoardCameraStateSchema, type BoardCapability, BoardColorId, BoardComposition, BoardCompositionSchema, BoardConnection, BoardConnectionAnchor, BoardConnectionAnchorSchema, BoardConnectionDirection, BoardConnectionEndpoint, BoardConnectionEndpointSchema, BoardConnectionInput, BoardConnectionLine, BoardConnectionPatch, BoardConnectionPatchSchema, BoardConnectionRecord, BoardConnectionRouting, BoardConnectionRoutingConfig, BoardConnectionRoutingSchema, BoardConnectionSchema, BoardConnectionSide, BoardConnectionStyle, BoardConnectionStyleSchema, BoardConnectionWaypointSchema, BoardDeleteReason, BoardDiagnostic, BoardEasing, BoardEasingSchema, BoardEffect, BoardEffectSchema, BoardGeoKind, BoardManifest, BoardManifestSchema, BoardNodeInput, BoardNodeRecord, BoardOperation, BoardPlaybackPolicy, BoardPlaybackPolicySchema, BoardProceduralClip, BoardProceduralClipSchema, BoardRecord, BoardRelationSchema, type BoardRenderCost, BoardTimelineMarker, BoardTimelineMarkerSchema, BoardTrack, BoardTrackInterpolation, BoardTrackSchema, BoardValidationResult, DEFAULT_BOARD_CONNECTION_ROUTING, DEFAULT_BOARD_CONNECTION_STYLE, DEFAULT_BOARD_RELATION, InvalidBoardFileError, connectionNodeIds, connectionOtherNodeId, connectionTouchesNode, createBoardConnection, flipBoardConnection, isBoardPath, normalizeBoardConnectionStyle, parseBoardManifest, serializeBoardManifest };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import "./board-constants.js";
|
|
1
|
+
import { BOARD_BUILTIN_CAPABILITIES, DEFAULT_BOARD_RENDER_LIMITS } from "./board-constants.js";
|
|
2
2
|
import { AUTO_BOARD_CONNECTION_ANCHOR, BOARD_CONNECTION_DIRECTIONS, BOARD_CONNECTION_LINES, BOARD_CONNECTION_ROUTINGS, BOARD_CONNECTION_SIDES, BoardConnectionAnchorSchema, BoardConnectionEndpointSchema, BoardConnectionPatchSchema, BoardConnectionRoutingSchema, BoardConnectionSchema, BoardConnectionStyleSchema, BoardConnectionWaypointSchema, BoardRelationSchema, DEFAULT_BOARD_CONNECTION_ROUTING, DEFAULT_BOARD_CONNECTION_STYLE, DEFAULT_BOARD_RELATION, connectionNodeIds, connectionOtherNodeId, connectionTouchesNode, createBoardConnection, flipBoardConnection, normalizeBoardConnectionStyle } from "./board-connection.js";
|
|
3
|
-
import {
|
|
3
|
+
import { BOARD_ANIMATION_CHANNELS, BOARD_EASINGS, BoardAnimationTargetSchema, BoardCompositionInputSchema, BoardCompositionPlaybackSchema, BoardCompositionSchema, BoardEasingSchema, BoardProceduralClipSchema, BoardTimelineMarkerSchema, BoardTimelineSchema, BoardTrackSchema, parseBoardCompositionInput } from "./board-composition.js";
|
|
4
|
+
import { BoardArrowAuthoringItemSchema, BoardAudioAuthoringItemSchema, BoardAuthoringItemSchema, BoardBuiltinAuthoringItemSchema, BoardDrawAuthoringItemSchema, BoardExtensionAuthoringItemSchema, BoardFileAuthoringItemSchema, BoardFrameAuthoringItemSchema, BoardGeoAuthoringItemSchema, BoardImageAuthoringItemSchema, BoardItemPatchSchema, BoardItemSourceSchema, BoardItemStyleSchema, BoardSemanticCommandSchema, BoardTaskAuthoringItemSchema, BoardTextAuthoringItemSchema, BoardVideoAuthoringItemSchema, isSafeBoardSourcePath } from "./board-authoring.js";
|
|
5
|
+
import { BOARD_DOCUMENT_KIND, BOARD_EXTENSION, BOARD_MANIFEST_KIND, BoardAssetRefSchema, BoardCameraFocusParamsSchema, BoardCameraFocusSchema, BoardCameraStateSchema, BoardEffectSchema, BoardManifestSchema, InvalidBoardFileError, isBoardPath, parseBoardManifest, serializeBoardManifest } from "./board.js";
|
|
6
|
+
import { estimateBuiltinBoardClipCost, validateBuiltinBoardClip } from "./board-capability-registry.js";
|
|
7
|
+
import { BOARD_COLOR_IDS, BOARD_GEO_KINDS, BOARD_NATIVE_NODE_TYPES, BoardColorIdSchema, BoardGeoKindSchema } from "./board-node.js";
|
|
8
|
+
import "./board-codec.js";
|
|
4
9
|
import { BOARD_CONTENT_KINDS, BoardContentKindSchema, BoardPortSchema } from "./board-content.js";
|
|
5
|
-
import
|
|
10
|
+
import "./board-upgrade.js";
|
|
6
11
|
import { BoardAwarenessDrawPointSchema, BoardAwarenessFrameSchema, BoardAwarenessGestureSchema, BoardAwarenessNodePreviewSchema, BoardAwarenessPointSchema, BoardAwarenessStateUpdateSchema, BoardAwarenessUpdateSchema } from "./realtime/board-awareness.js";
|
|
7
12
|
import { SHORT_UUID_PATTERN, UUID_OR_SHORT_UUID_PATTERN, UUID_PATTERN, UUID_SHAPE_PATTERN } from "./identifiers.js";
|
|
8
13
|
import { COHUB_SOURCE_HEADER } from "./provenance.js";
|
|
@@ -11,4 +16,4 @@ import "./ui-command.js";
|
|
|
11
16
|
import "./work-surface.js";
|
|
12
17
|
import "./work-view-stats.js";
|
|
13
18
|
import { WORK_PROMOTION_EVENT_KEYS } from "./work-promotion-stats.js";
|
|
14
|
-
export { AUTO_BOARD_CONNECTION_ANCHOR, BOARD_COLOR_IDS, BOARD_CONNECTION_DIRECTIONS, BOARD_CONNECTION_LINES, BOARD_CONNECTION_ROUTINGS, BOARD_CONNECTION_SIDES, BOARD_CONTENT_KINDS, BOARD_DOCUMENT_KIND, BOARD_EXTENSION, BOARD_GEO_KINDS, BOARD_MANIFEST_KIND, BOARD_NATIVE_NODE_TYPES, BoardAssetRefSchema, BoardAwarenessDrawPointSchema, BoardAwarenessFrameSchema, BoardAwarenessGestureSchema, BoardAwarenessNodePreviewSchema, BoardAwarenessPointSchema, BoardAwarenessStateUpdateSchema, BoardAwarenessUpdateSchema, BoardCameraFocusParamsSchema, BoardCameraFocusSchema, BoardCameraStateSchema,
|
|
19
|
+
export { AUTO_BOARD_CONNECTION_ANCHOR, BOARD_ANIMATION_CHANNELS, BOARD_BUILTIN_CAPABILITIES, BOARD_COLOR_IDS, BOARD_CONNECTION_DIRECTIONS, BOARD_CONNECTION_LINES, BOARD_CONNECTION_ROUTINGS, BOARD_CONNECTION_SIDES, BOARD_CONTENT_KINDS, BOARD_DOCUMENT_KIND, BOARD_EASINGS, BOARD_EXTENSION, BOARD_GEO_KINDS, BOARD_MANIFEST_KIND, BOARD_NATIVE_NODE_TYPES, BoardAnimationTargetSchema, BoardArrowAuthoringItemSchema, BoardAssetRefSchema, BoardAudioAuthoringItemSchema, BoardAuthoringItemSchema, BoardAwarenessDrawPointSchema, BoardAwarenessFrameSchema, BoardAwarenessGestureSchema, BoardAwarenessNodePreviewSchema, BoardAwarenessPointSchema, BoardAwarenessStateUpdateSchema, BoardAwarenessUpdateSchema, BoardBuiltinAuthoringItemSchema, BoardCameraFocusParamsSchema, BoardCameraFocusSchema, BoardCameraStateSchema, BoardColorIdSchema, BoardCompositionInputSchema, BoardCompositionPlaybackSchema, BoardCompositionSchema, BoardConnectionAnchorSchema, BoardConnectionEndpointSchema, BoardConnectionPatchSchema, BoardConnectionRoutingSchema, BoardConnectionSchema, BoardConnectionStyleSchema, BoardConnectionWaypointSchema, BoardContentKindSchema, BoardDrawAuthoringItemSchema, BoardEasingSchema, BoardEffectSchema, BoardExtensionAuthoringItemSchema, BoardFileAuthoringItemSchema, BoardFrameAuthoringItemSchema, BoardGeoAuthoringItemSchema, BoardGeoKindSchema, BoardImageAuthoringItemSchema, BoardItemPatchSchema, BoardItemSourceSchema, BoardItemStyleSchema, BoardManifestSchema, BoardPortSchema, BoardProceduralClipSchema, BoardRelationSchema, BoardSemanticCommandSchema, BoardTaskAuthoringItemSchema, BoardTextAuthoringItemSchema, BoardTimelineMarkerSchema, BoardTimelineSchema, BoardTrackSchema, BoardVideoAuthoringItemSchema, COHUB_SOURCE_HEADER, DEFAULT_BOARD_CONNECTION_ROUTING, DEFAULT_BOARD_CONNECTION_STYLE, DEFAULT_BOARD_RELATION, DEFAULT_BOARD_RENDER_LIMITS, InvalidBoardFileError, RESERVED_PLATFORM_PATH_SEGMENTS, SHORT_UUID_PATTERN, UUID_OR_SHORT_UUID_PATTERN, UUID_PATTERN, UUID_SHAPE_PATTERN, WORK_PROMOTION_EVENT_KEYS, connectionNodeIds, connectionOtherNodeId, connectionTouchesNode, createBoardConnection, estimateBuiltinBoardClipCost, flipBoardConnection, isBoardPath, isSafeBoardSourcePath, normalizeBoardConnectionStyle, parseBoardCompositionInput, parseBoardManifest, serializeBoardManifest, validateBuiltinBoardClip };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BoardCapability, BoardCoordinateSpace, BoardRenderCost } from "./protocol/dist/board-constants.js";
|
|
2
|
-
import {
|
|
2
|
+
import { BoardAnimationTarget, BoardComposition, BoardEasing, BoardProceduralClip, BoardTimelineMarker, BoardTrack } from "./protocol/dist/board-composition.js";
|
|
3
|
+
import { BoardAssetRef, BoardCameraFocus, BoardCameraFocusParams, BoardCameraState, BoardDeleteReason, BoardDiagnostic, BoardEffect, BoardManifest, BoardNodeInput, BoardNodeRecord, BoardOperation, BoardPlaybackPolicy, BoardRecord, BoardValidationResult } from "./protocol/dist/board.js";
|
|
3
4
|
import "./protocol/dist/index.js";
|
|
4
5
|
//#region src/types.d.ts
|
|
5
6
|
type UserProfile = {
|
|
@@ -83,10 +83,24 @@ The Work runs inside a Cohub-hosted iframe (`window.parent !== window`). The
|
|
|
83
83
|
SDK communicates with the parent window via `postMessage` to request tokens
|
|
84
84
|
and context. This is the normal case when a viewer opens a Work through Cohub.
|
|
85
85
|
|
|
86
|
-
- `client.context()` returns the **real** `space.id`, `work.id`,
|
|
87
|
-
permission scopes from the host.
|
|
86
|
+
- `client.context()` returns the **real** `space.id`, `work.id`, current viewer,
|
|
87
|
+
and permission scopes from the host.
|
|
88
|
+
- A Work opened through `cohub ui preview` also receives an `invocation`
|
|
89
|
+
snapshot with the originating `spaceId`, `sessionId`, `turnId`, and
|
|
90
|
+
`toolCallId` when available. The invocation Space may differ from the Work's
|
|
91
|
+
own `space.id`.
|
|
88
92
|
- `client.auth.request()` triggers an in-shell consent flow (no popup window).
|
|
89
93
|
|
|
94
|
+
```js
|
|
95
|
+
const ctx = await client.context();
|
|
96
|
+
console.log(ctx.viewer?.userUuid ?? null);
|
|
97
|
+
console.log(ctx.invocation?.sessionId ?? null);
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Invocation fields describe where the preview came from. They are identifiers,
|
|
101
|
+
not authorization: API access remains controlled by the Work session token and
|
|
102
|
+
its scopes.
|
|
103
|
+
|
|
90
104
|
### Broker mode (standalone deployment)
|
|
91
105
|
|
|
92
106
|
The Work is accessed as a standalone page (`window.parent === window`), e.g.
|
|
@@ -183,6 +197,7 @@ but **not active** until the viewer approves them through a consent dialog
|
|
|
183
197
|
triggered by `client.auth.request()`. These are **action** permissions.
|
|
184
198
|
|
|
185
199
|
```
|
|
200
|
+
taskrun.view — read Task Runs the viewer can already access
|
|
186
201
|
session.prompt.readonly — send read-only prompts (no side effects)
|
|
187
202
|
session.prompt.fullaccess — send prompts with full access (write, create sessions)
|
|
188
203
|
generation.create — create generation tasks (image/video/audio)
|
|
@@ -199,7 +214,8 @@ user.usage.read — read the viewer's aggregated usage
|
|
|
199
214
|
`session.prompt.fullaccess` lets you **send** a prompt, but does **not** let
|
|
200
215
|
you **read** the result — that needs `session.view` (a work scope).
|
|
201
216
|
`generation.create` lets you **create** a generation task, but reading its
|
|
202
|
-
result needs `taskrun.view
|
|
217
|
+
result needs `taskrun.view`, either from the publishing Space's work scopes or
|
|
218
|
+
from viewer authorization checked against the requested Space or Session.
|
|
203
219
|
|
|
204
220
|
### Complete API → scope mapping
|
|
205
221
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neta-art/cohub",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Cohub SDK for spaces, sessions, boards, and realtime agent collaboration.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"private": false,
|
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
"tsdown": "^0.22.7",
|
|
83
83
|
"tsx": "4.23.1",
|
|
84
84
|
"typescript": "^7.0.2",
|
|
85
|
+
"@cohub/core": "1.1.1",
|
|
85
86
|
"@cohub/protocol": "2.0.0"
|
|
86
87
|
},
|
|
87
88
|
"peerDependencies": {
|
|
@@ -100,7 +101,7 @@
|
|
|
100
101
|
"build": "tsdown",
|
|
101
102
|
"lint": "biome lint .",
|
|
102
103
|
"lint:fix": "biome lint --write .",
|
|
103
|
-
"test": "node ../../scripts/test/run.mjs 'src/**/*.test.ts' 'tests/**/*.test.ts'",
|
|
104
|
+
"test": "node ../../scripts/test/run.mjs --test-concurrency=2 'src/**/*.test.ts' 'tests/**/*.test.ts'",
|
|
104
105
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
105
106
|
}
|
|
106
107
|
}
|
package/dist/board/nodes.d.ts
DELETED
|
@@ -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 };
|
package/dist/board/nodes.js
DELETED
|
@@ -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 };
|