@neta-art/cohub 8.24.0 → 9.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 (159) hide show
  1. package/dist/board/animation.d.ts +57 -181
  2. package/dist/board/animation.js +374 -220
  3. package/dist/board/core/arrow-geometry.d.ts +33 -18
  4. package/dist/board/core/arrow-geometry.js +283 -52
  5. package/dist/board/core/draw-geometry.d.ts +22 -36
  6. package/dist/board/core/draw-geometry.js +148 -85
  7. package/dist/board/core/export-assets.d.ts +3 -6
  8. package/dist/board/core/export-assets.js +0 -2
  9. package/dist/board/core/export-plan.d.ts +12 -63
  10. package/dist/board/core/export-plan.js +55 -94
  11. package/dist/board/core/palette.d.ts +4 -21
  12. package/dist/board/core/palette.js +8 -13
  13. package/dist/board/core/scene.d.ts +33 -0
  14. package/dist/board/core/scene.js +302 -0
  15. package/dist/board/core/shape-definition.d.ts +12 -24
  16. package/dist/board/core/shape-definition.js +0 -19
  17. package/dist/board/core/shape-types.d.ts +6 -120
  18. package/dist/board/core/shape-types.js +5 -5
  19. package/dist/board/core/text-metrics.d.ts +8 -11
  20. package/dist/board/core/text-metrics.js +5 -34
  21. package/dist/board/core/tool-styles.d.ts +6 -16
  22. package/dist/board/core/tool-styles.js +17 -25
  23. package/dist/board/export/index.d.ts +10 -17
  24. package/dist/board/export/index.js +22 -21
  25. package/dist/board/export/scene.d.ts +10 -16
  26. package/dist/board/export/scene.js +17 -30
  27. package/dist/board/geometry.d.ts +27 -56
  28. package/dist/board/geometry.js +7 -67
  29. package/dist/board/headless/index.d.ts +6 -27
  30. package/dist/board/headless/index.js +4 -19
  31. package/dist/board/headless/sketch.d.ts +19 -0
  32. package/dist/board/headless/sketch.js +146 -0
  33. package/dist/board/image-key.d.ts +2 -12
  34. package/dist/board/image-key.js +3 -13
  35. package/dist/board/index.d.ts +18 -20
  36. package/dist/board/index.js +17 -17
  37. package/dist/board/media-playback.d.ts +3 -6
  38. package/dist/board/media-playback.js +6 -6
  39. package/dist/board/presets.d.ts +150 -0
  40. package/dist/board/presets.js +226 -0
  41. package/dist/board/render/board-background.d.ts +5 -3
  42. package/dist/board/render/board-background.js +8 -7
  43. package/dist/board/render/clip.d.ts +14 -0
  44. package/dist/board/render/clip.js +47 -0
  45. package/dist/board/render/index.d.ts +8 -5
  46. package/dist/board/render/index.js +7 -4
  47. package/dist/board/render/media-interaction.d.ts +4 -5
  48. package/dist/board/render/media-interaction.js +1 -2
  49. package/dist/board/render/palette.d.ts +6 -2
  50. package/dist/board/render/palette.js +7 -1
  51. package/dist/board/render/renderers/arrow-card-renderer.js +69 -71
  52. package/dist/board/render/renderers/audio-card-renderer.js +3 -3
  53. package/dist/board/render/renderers/base-card-renderer.d.ts +6 -17
  54. package/dist/board/render/renderers/base-card-renderer.js +1 -24
  55. package/dist/board/render/renderers/board-renderer-registry.d.ts +20 -50
  56. package/dist/board/render/renderers/board-renderer-registry.js +6 -7
  57. package/dist/board/render/renderers/draw-card-renderer.js +89 -56
  58. package/dist/board/render/renderers/effect-card-renderer.d.ts +6 -0
  59. package/dist/board/render/renderers/effect-card-renderer.js +197 -0
  60. package/dist/board/render/renderers/far-plate.d.ts +4 -21
  61. package/dist/board/render/renderers/far-plate.js +15 -34
  62. package/dist/board/render/renderers/file-card-renderer.d.ts +4 -25
  63. package/dist/board/render/renderers/file-card-renderer.js +8 -58
  64. package/dist/board/render/renderers/frame-card-renderer.js +28 -28
  65. package/dist/board/render/renderers/image-card-renderer.d.ts +4 -3
  66. package/dist/board/render/renderers/image-card-renderer.js +0 -9
  67. package/dist/board/render/renderers/shape-card-renderer.d.ts +9 -0
  68. package/dist/board/render/renderers/shape-card-renderer.js +240 -0
  69. package/dist/board/render/renderers/sketch-card-renderer.d.ts +5 -0
  70. package/dist/board/render/renderers/sketch-card-renderer.js +98 -0
  71. package/dist/board/render/renderers/task-card-renderer.d.ts +0 -1
  72. package/dist/board/render/renderers/task-card-renderer.js +14 -16
  73. package/dist/board/render/renderers/text-card-renderer.d.ts +1 -3
  74. package/dist/board/render/renderers/text-card-renderer.js +56 -46
  75. package/dist/board/render/renderers/unknown-card-renderer.js +4 -10
  76. package/dist/board/render/renderers/video-card-renderer.d.ts +4 -2
  77. package/dist/board/render/renderers/video-card-renderer.js +2 -1
  78. package/dist/board/render/sketch-host.d.ts +14 -0
  79. package/dist/board/render/sketch-host.js +216 -0
  80. package/dist/board/render/stroke.d.ts +12 -0
  81. package/dist/board/render/stroke.js +90 -0
  82. package/dist/board/render/text-measurement.d.ts +6 -26
  83. package/dist/board/render/text-measurement.js +11 -30
  84. package/dist/board/replay.d.ts +6 -31
  85. package/dist/board/replay.js +45 -203
  86. package/dist/board/runtime/board-player.d.ts +24 -0
  87. package/dist/board/runtime/board-player.js +161 -0
  88. package/dist/board/task.d.ts +2 -10
  89. package/dist/board/task.js +1 -10
  90. package/dist/chunks/environment.d.ts +2291 -3864
  91. package/dist/chunks/host-bridge.d.ts +253 -0
  92. package/dist/chunks/http.d.ts +233 -58
  93. package/dist/chunks/http.js +1046 -1028
  94. package/dist/chunks/transport.js +113 -59
  95. package/dist/chunks/websocket.d.ts +1 -1
  96. package/dist/chunks/websocket.js +1 -1
  97. package/dist/host-bridge.d.ts +54 -0
  98. package/dist/host-bridge.js +322 -0
  99. package/dist/http.d.ts +3 -3
  100. package/dist/index.d.ts +74 -191
  101. package/dist/index.js +2032 -1186
  102. package/dist/protocol/dist/board-constants.d.ts +1 -29
  103. package/dist/protocol/dist/board-constants.js +2 -115
  104. package/dist/protocol/dist/board-layout.d.ts +59 -0
  105. package/dist/protocol/dist/board-layout.js +482 -0
  106. package/dist/protocol/dist/board-model.d.ts +2052 -0
  107. package/dist/protocol/dist/board-model.js +592 -0
  108. package/dist/protocol/dist/board-patch.d.ts +86 -0
  109. package/dist/protocol/dist/board-patch.js +734 -0
  110. package/dist/protocol/dist/board-schema.d.ts +33 -0
  111. package/dist/protocol/dist/board-schema.js +59 -0
  112. package/dist/protocol/dist/board-upgrade.d.ts +1 -0
  113. package/dist/protocol/dist/board-url.d.ts +1 -3
  114. package/dist/protocol/dist/board-url.js +2 -2
  115. package/dist/protocol/dist/board.d.ts +37 -232
  116. package/dist/protocol/dist/board.js +62 -160
  117. package/dist/protocol/dist/display/actions.d.ts +1 -0
  118. package/dist/protocol/dist/display/index.d.ts +2 -0
  119. package/dist/protocol/dist/index.d.ts +11 -12
  120. package/dist/protocol/dist/model/metrics.d.ts +2 -0
  121. package/dist/protocol/dist/model/session.d.ts +2 -1
  122. package/dist/protocol/dist/realtime/types.d.ts +2 -2
  123. package/dist/protocol/dist/runtime/index.d.ts +1 -0
  124. package/dist/space-picker.d.ts +1 -0
  125. package/dist/space-picker.js +1 -0
  126. package/dist/types.d.ts +2 -5
  127. package/package.json +9 -1
  128. package/dist/board/core/connections.d.ts +0 -108
  129. package/dist/board/core/connections.js +0 -455
  130. package/dist/board/mutation.d.ts +0 -6
  131. package/dist/board/mutation.js +0 -14
  132. package/dist/board/render/connection-layer.d.ts +0 -53
  133. package/dist/board/render/connection-layer.js +0 -375
  134. package/dist/board/render/renderers/geo-card-renderer.d.ts +0 -5
  135. package/dist/board/render/renderers/geo-card-renderer.js +0 -127
  136. package/dist/board/semantic-document.d.ts +0 -37
  137. package/dist/board/semantic-document.js +0 -288
  138. package/dist/board/semantic-mutation.d.ts +0 -10
  139. package/dist/board/semantic-mutation.js +0 -209
  140. package/dist/protocol/dist/board-animation.js +0 -34
  141. package/dist/protocol/dist/board-authoring.d.ts +0 -1326
  142. package/dist/protocol/dist/board-authoring.js +0 -302
  143. package/dist/protocol/dist/board-capability-registry.d.ts +0 -2
  144. package/dist/protocol/dist/board-capability-registry.js +0 -123
  145. package/dist/protocol/dist/board-codec.d.ts +0 -3
  146. package/dist/protocol/dist/board-codec.js +0 -383
  147. package/dist/protocol/dist/board-composition.d.ts +0 -383
  148. package/dist/protocol/dist/board-composition.js +0 -310
  149. package/dist/protocol/dist/board-connection.d.ts +0 -317
  150. package/dist/protocol/dist/board-connection.js +0 -219
  151. package/dist/protocol/dist/board-document.d.ts +0 -1566
  152. package/dist/protocol/dist/board-document.js +0 -456
  153. package/dist/protocol/dist/board-effect.d.ts +0 -96
  154. package/dist/protocol/dist/board-effect.js +0 -54
  155. package/dist/protocol/dist/board-geometry.d.ts +0 -15
  156. package/dist/protocol/dist/board-geometry.js +0 -137
  157. package/dist/protocol/dist/board-node.d.ts +0 -8
  158. package/dist/protocol/dist/board-node.js +0 -252
  159. /package/dist/protocol/dist/{board-animation.d.ts → host-bridge.d.ts} +0 -0
@@ -0,0 +1,33 @@
1
+ //#region ../protocol/dist/board-schema.d.ts
2
+ type JsonSchema = Record<string, unknown>;
3
+ declare const BOARD_SCHEMA_TARGETS: readonly ["board", "animation", "track", "camera", ...("arrow" | "audio" | "draw" | "effect" | "file" | "frame" | "image" | "shape" | "sketch" | "task" | "text" | "video")[]];
4
+ type BoardJsonSchemaResult = {
5
+ schema?: JsonSchema;
6
+ properties?: Array<{
7
+ property: string;
8
+ kind: string;
9
+ }>;
10
+ kinds?: Record<string, {
11
+ description: string;
12
+ parameters: Record<string, string>;
13
+ }>;
14
+ };
15
+ declare function boardJsonSchema(target: string): BoardJsonSchemaResult | null;
16
+ declare function boardSchemaOverview(): {
17
+ units: {
18
+ time: string;
19
+ rotation: string;
20
+ length: string;
21
+ };
22
+ types: ("arrow" | "audio" | "draw" | "effect" | "file" | "frame" | "image" | "shape" | "sketch" | "task" | "text" | "video")[];
23
+ colors: {
24
+ tokens: readonly ["brand", "neutral", "black", "white", "blue", "green", "amber", "violet", "rose"];
25
+ css: string;
26
+ themed: string;
27
+ };
28
+ properties: {
29
+ [k: string]: string[];
30
+ };
31
+ };
32
+ //#endregion
33
+ export { BOARD_SCHEMA_TARGETS, BoardJsonSchemaResult, boardJsonSchema, boardSchemaOverview };
@@ -0,0 +1,59 @@
1
+ import { BOARD_CAMERA_TARGET, BOARD_COLOR_TOKENS, BOARD_EFFECT_KINDS, BOARD_EFFECT_KIND_INFO, BOARD_ITEM_SCHEMAS, BOARD_ITEM_TYPES, BoardAnimationHeaderSchema, BoardSettingsSchema, BoardTrackSchema, isBuiltinItemType } from "./board-model.js";
2
+ import { listBoardProperties } from "./board-patch.js";
3
+ import { z } from "zod";
4
+ //#region ../protocol/dist/board-schema.js
5
+ function toJsonSchema(schema) {
6
+ const { $schema: _schema, ...rest } = z.toJSONSchema(schema, {
7
+ io: "input",
8
+ unrepresentable: "any"
9
+ });
10
+ return rest;
11
+ }
12
+ const BOARD_SCHEMA_TARGETS = [
13
+ "board",
14
+ "animation",
15
+ "track",
16
+ BOARD_CAMERA_TARGET,
17
+ ...BOARD_ITEM_TYPES
18
+ ];
19
+ function boardJsonSchema(target) {
20
+ if (target === "board") return { schema: toJsonSchema(BoardSettingsSchema) };
21
+ if (target === "animation") return {
22
+ schema: toJsonSchema(BoardAnimationHeaderSchema.extend({ tracks: z.record(z.string(), BoardTrackSchema).optional() })),
23
+ properties: listBoardProperties("animation")
24
+ };
25
+ if (target === "track") return { schema: toJsonSchema(BoardTrackSchema) };
26
+ if (target === "effect") return {
27
+ schema: toJsonSchema(BOARD_ITEM_SCHEMAS.effect),
28
+ properties: listBoardProperties("effect"),
29
+ kinds: Object.fromEntries(BOARD_EFFECT_KINDS.map((kind) => [kind, BOARD_EFFECT_KIND_INFO[kind]]))
30
+ };
31
+ if (target === "camera") return { properties: listBoardProperties(BOARD_CAMERA_TARGET) };
32
+ if (!isBuiltinItemType(target)) return null;
33
+ return {
34
+ schema: toJsonSchema(BOARD_ITEM_SCHEMAS[target]),
35
+ properties: listBoardProperties(target)
36
+ };
37
+ }
38
+ function boardSchemaOverview() {
39
+ return {
40
+ units: {
41
+ time: "milliseconds",
42
+ rotation: "degrees",
43
+ length: "board units (1 = 1 CSS px at zoom 1)"
44
+ },
45
+ types: BOARD_ITEM_TYPES,
46
+ colors: {
47
+ tokens: BOARD_COLOR_TOKENS,
48
+ css: "any CSS color",
49
+ themed: "{ light, dark }"
50
+ },
51
+ properties: Object.fromEntries([
52
+ ...BOARD_ITEM_TYPES,
53
+ BOARD_CAMERA_TARGET,
54
+ "animation"
55
+ ].map((target) => [target, listBoardProperties(target).map((entry) => entry.property)]))
56
+ };
57
+ }
58
+ //#endregion
59
+ export { BOARD_SCHEMA_TARGETS, boardJsonSchema, boardSchemaOverview };
@@ -0,0 +1 @@
1
+ import "./board-model.js";
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod";
2
2
  //#region ../protocol/dist/board-url.d.ts
3
- declare const BOARD_REMOTE_URL_MAX_LENGTH = 4096;
4
3
  declare function isPublicBoardRemoteAddress(value: string): boolean;
5
4
  /**
6
5
  * Normalize a browser-loadable public HTTP(S) URL. This blocks explicit local
@@ -8,6 +7,5 @@ declare function isPublicBoardRemoteAddress(value: string): boolean;
8
7
  * resolution to defend against rebinding.
9
8
  */
10
9
  declare function normalizeBoardRemoteUrl(value: unknown): string | undefined;
11
- declare const BoardRemoteUrlSchema: z.ZodString;
12
10
  //#endregion
13
- export { BOARD_REMOTE_URL_MAX_LENGTH, BoardRemoteUrlSchema, isPublicBoardRemoteAddress, normalizeBoardRemoteUrl };
11
+ export { isPublicBoardRemoteAddress, normalizeBoardRemoteUrl };
@@ -83,6 +83,6 @@ function normalizeBoardRemoteUrl(value) {
83
83
  return;
84
84
  }
85
85
  }
86
- const BoardRemoteUrlSchema = z.string().max(BOARD_REMOTE_URL_MAX_LENGTH).refine((value) => normalizeBoardRemoteUrl(value) !== void 0, { message: "URL must be a public HTTP(S) URL without credentials" });
86
+ z.string().max(BOARD_REMOTE_URL_MAX_LENGTH).refine((value) => normalizeBoardRemoteUrl(value) !== void 0, { message: "URL must be a public HTTP(S) URL without credentials" });
87
87
  //#endregion
88
- export { BOARD_REMOTE_URL_MAX_LENGTH, BoardRemoteUrlSchema, isPublicBoardRemoteAddress, normalizeBoardRemoteUrl };
88
+ export { BOARD_REMOTE_URL_MAX_LENGTH, isPublicBoardRemoteAddress, normalizeBoardRemoteUrl };
@@ -1,13 +1,7 @@
1
- import { BoardCapability, BoardCoordinateSpace, BoardRenderCost } from "./board-constants.js";
2
- import { BoardConnectionInput, BoardConnectionPatch, BoardConnectionRecord } from "./board-connection.js";
3
- import { BoardComposition } from "./board-composition.js";
4
- import { BoardAssetRef, BoardAssetRefSchema, BoardEffect, BoardEffectInput, BoardEffectInputSchema, BoardEffectSchema } from "./board-effect.js";
5
- import "./board-authoring.js";
1
+ import { BoardDelta, BoardPatch } from "./board-model.js";
6
2
  import { RequestSource } from "./provenance.js";
7
3
  import { z } from "zod";
8
4
  //#region ../protocol/dist/board.d.ts
9
- declare const BOARD_EXTENSION: ".board";
10
- declare const BOARD_DOCUMENT_KIND: "cohub.board";
11
5
  declare const BoardManifestSchema: z.ZodObject<{
12
6
  kind: z.ZodLiteral<"cohub.board.manifest">;
13
7
  version: z.ZodLiteral<1>;
@@ -17,250 +11,61 @@ declare const BoardManifestSchema: z.ZodObject<{
17
11
  type BoardManifest = z.infer<typeof BoardManifestSchema>;
18
12
  declare function parseBoardManifest(input: string | unknown): BoardManifest;
19
13
  declare function serializeBoardManifest(manifest: BoardManifest): string;
20
- declare const BoardCameraStateSchema: z.ZodObject<{
21
- centerX: z.ZodNumber;
22
- centerY: z.ZodNumber;
23
- zoom: z.ZodNumber;
24
- }, z.core.$strip>;
25
- declare const BoardCameraFocusSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
26
- type: z.ZodLiteral<"rect">;
27
- rect: z.ZodObject<{
28
- x: z.ZodNumber;
29
- y: z.ZodNumber;
30
- width: z.ZodNumber;
31
- height: z.ZodNumber;
32
- }, z.core.$strip>;
33
- }, z.core.$strip>, z.ZodObject<{
34
- type: z.ZodLiteral<"item">;
35
- itemId: z.ZodString;
36
- }, z.core.$strip>, z.ZodObject<{
37
- type: z.ZodLiteral<"items">;
38
- itemIds: z.ZodArray<z.ZodString>;
39
- }, z.core.$strip>, z.ZodObject<{
40
- type: z.ZodLiteral<"frame">;
41
- frameId: z.ZodString;
42
- }, z.core.$strip>], "type">;
43
- declare const BoardCameraFocusParamsSchema: z.ZodObject<{
44
- focus: z.ZodDiscriminatedUnion<[z.ZodObject<{
45
- type: z.ZodLiteral<"rect">;
46
- rect: z.ZodObject<{
47
- x: z.ZodNumber;
48
- y: z.ZodNumber;
49
- width: z.ZodNumber;
50
- height: z.ZodNumber;
51
- }, z.core.$strip>;
52
- }, z.core.$strip>, z.ZodObject<{
53
- type: z.ZodLiteral<"item">;
54
- itemId: z.ZodString;
55
- }, z.core.$strip>, z.ZodObject<{
56
- type: z.ZodLiteral<"items">;
57
- itemIds: z.ZodArray<z.ZodString>;
58
- }, z.core.$strip>, z.ZodObject<{
59
- type: z.ZodLiteral<"frame">;
60
- frameId: z.ZodString;
61
- }, z.core.$strip>], "type">;
62
- fit: z.ZodDefault<z.ZodEnum<{
63
- contain: "contain";
64
- cover: "cover";
65
- }>>;
66
- padding: z.ZodDefault<z.ZodNumber>;
67
- minZoom: z.ZodOptional<z.ZodNumber>;
68
- maxZoom: z.ZodOptional<z.ZodNumber>;
69
- }, z.core.$strip>;
70
- type BoardCameraState = z.infer<typeof BoardCameraStateSchema>;
71
- type BoardCameraFocus = z.infer<typeof BoardCameraFocusSchema>;
72
- type BoardCameraFocusParams = z.infer<typeof BoardCameraFocusParamsSchema>;
73
- type BoardRecord = {
74
- id: string;
75
- spaceId: string;
76
- title: string;
77
- version: number;
78
- metadata: Record<string, unknown>;
79
- createdAt: string | null;
80
- updatedAt: string | null;
81
- };
82
- type BoardNodeRecord = {
83
- boardId: string;
84
- nodeId: string;
85
- type: string;
86
- parentId: string | null;
87
- orderKey: string | null;
88
- x: number;
89
- y: number;
90
- width: number;
91
- height: number;
92
- rotation: number;
93
- refKind: string | null;
94
- refPath: string | null;
95
- refUrl: string | null;
96
- view: Record<string, unknown>;
97
- style: Record<string, unknown>;
98
- data: Record<string, unknown>;
99
- version: number;
100
- createdAt: string | null;
101
- updatedAt: string | null;
102
- };
103
- type BoardNodeInput = Omit<BoardNodeRecord, "boardId" | "version" | "createdAt" | "updatedAt">;
104
- declare const BOARD_DELETE_REASONS: readonly ["user-delete", "orphan-cleanup", "layout-replace", "placeholder-cascade", "node-cascade"];
105
- type BoardDeleteReason = (typeof BOARD_DELETE_REASONS)[number] | (string & {});
106
- type BoardOperationBase = {
107
- opId?: string;
108
- /** Optional local undo hint. Servers recompute authoritative inverse data. */
109
- inverse?: Record<string, unknown>;
110
- };
111
- type BoardOperation = (BoardOperationBase & {
112
- type: "board.patch";
113
- payload: {
114
- patch: {
115
- title?: string;
116
- metadata?: Record<string, unknown>;
117
- metadataPatch?: Record<string, unknown>;
118
- };
119
- };
120
- }) | (BoardOperationBase & {
121
- type: "node.create";
122
- payload: {
123
- node: BoardNodeInput;
124
- };
125
- }) | (BoardOperationBase & {
126
- type: "node.patch";
127
- payload: {
128
- nodeId: string;
129
- patch: Partial<BoardNodeInput>;
130
- };
131
- }) | (BoardOperationBase & {
132
- type: "node.delete";
133
- payload: {
134
- nodeId: string;
135
- reason?: BoardDeleteReason;
136
- };
137
- }) | (BoardOperationBase & {
138
- type: "connection.create";
139
- payload: {
140
- connection: BoardConnectionInput;
141
- };
142
- }) | (BoardOperationBase & {
143
- type: "connection.patch";
144
- payload: {
145
- connectionId: string;
146
- patch: BoardConnectionPatch;
147
- };
148
- }) | (BoardOperationBase & {
149
- type: "connection.delete";
150
- payload: {
151
- connectionId: string;
152
- reason?: BoardDeleteReason;
153
- };
154
- }) | (BoardOperationBase & {
155
- type: "effect.upsert";
156
- payload: {
157
- effect: Omit<BoardEffect, "boardId" | "revision">;
158
- };
159
- }) | (BoardOperationBase & {
160
- type: "effect.delete";
161
- payload: {
162
- effectId: string;
163
- };
164
- }) | (BoardOperationBase & {
165
- type: "composition.apply";
166
- payload: {
167
- composition: Omit<BoardComposition, "revision">;
168
- };
169
- }) | (BoardOperationBase & {
170
- type: "composition.delete";
171
- payload: {
172
- compositionId: string;
173
- };
174
- });
175
- type BoardMutationReceipt = {
176
- mutationId: string;
177
- status: "applied" | "validated";
178
- outcome: "applied" | "noop" | "dry-run";
179
- replayed: boolean;
180
- board: {
181
- id: string;
182
- version: number;
183
- };
184
- changed: {
185
- items: string[];
186
- connections: string[];
187
- effects: string[];
188
- compositions: string[];
189
- board: boolean;
190
- orderChanged: boolean;
191
- };
192
- };
193
- type BoardDiagnostic = {
194
- severity: "info" | "warning" | "error";
195
- code: string;
196
- message: string;
197
- path?: string;
198
- adaptation?: Record<string, unknown>;
199
- expected?: string;
200
- received?: unknown;
201
- allowedValues?: readonly string[];
202
- coordinateSpace?: BoardCoordinateSpace;
203
- };
204
- type BoardValidationResult = {
205
- valid: boolean;
206
- diagnostics: BoardDiagnostic[];
207
- peakCost: BoardRenderCost;
208
- };
209
- /**
210
- * One applied Board transaction as recorded in the log, with the server-computed
211
- * inverse of every operation. Read-only: replay walks the log in either
212
- * direction without touching Board rows.
213
- */
14
+ declare function isBoardPath(path: string): boolean;
214
15
  type BoardTransactionRecord = {
215
16
  id: string;
216
- txId: string;
17
+ mutationId: string;
217
18
  baseVersion: number;
218
- /** Board version this transaction produced. */
219
19
  version: number;
220
20
  actorId: string;
221
21
  clientId: string | null;
222
- undoGroupId: string | null;
223
22
  source: RequestSource | null;
224
23
  createdAt: string;
225
- operations: BoardTransactionOperation[];
226
- };
227
- type BoardTransactionOperation = {
228
- type: BoardOperation["type"];
229
- payload: Record<string, unknown>;
230
- inverse: Record<string, unknown> | null;
24
+ before: BoardDelta | null;
25
+ after: BoardDelta | null;
231
26
  };
232
- /**
233
- * A page of the transaction log, newest first. The newest page (no `before`)
234
- * carries the current rows unless `snapshot=false`, so a replay can start from
235
- * the live state and walk inverses backwards; older pages carry transactions only.
236
- */
237
- type BoardTransactionsPage = {
238
- board: {
239
- id: string;
240
- version: number;
241
- };
27
+ type BoardHistoryPage = {
28
+ version: number;
242
29
  transactions: BoardTransactionRecord[];
243
- /** Version to pass as `before` for the next older page, or null when exhausted. */
244
30
  nextBefore: number | null;
245
- snapshot?: {
246
- board: BoardRecord;
247
- nodes: BoardNodeRecord[];
248
- connections: BoardConnectionRecord[];
249
- };
250
31
  };
251
32
  type BoardPlaybackStatus = "playing" | "paused" | "stopped";
252
33
  type BoardPlaybackSnapshot = {
253
- boardId: string;
254
34
  playbackId: string;
255
- compositionId: string;
256
- compositionRevision: number;
257
- playbackRevision: number;
35
+ animationId: string;
36
+ animationRevision: number;
37
+ revision: number;
258
38
  status: BoardPlaybackStatus;
259
39
  position: number;
260
40
  effectiveAt: number;
261
41
  timeScale: number;
262
42
  seed: string;
43
+ commandId: string;
263
44
  };
264
- declare function isBoardPath(path: string): boolean;
45
+ declare const BoardPlaybackCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
46
+ commandId: z.ZodString;
47
+ type: z.ZodLiteral<"play">;
48
+ animationId: z.ZodString;
49
+ position: z.ZodOptional<z.ZodNumber>;
50
+ timeScale: z.ZodOptional<z.ZodNumber>;
51
+ seed: z.ZodOptional<z.ZodString>;
52
+ }, z.core.$strict>, z.ZodObject<{
53
+ commandId: z.ZodString;
54
+ type: z.ZodLiteral<"pause">;
55
+ }, z.core.$strict>, z.ZodObject<{
56
+ commandId: z.ZodString;
57
+ type: z.ZodLiteral<"resume">;
58
+ }, z.core.$strict>, z.ZodObject<{
59
+ commandId: z.ZodString;
60
+ type: z.ZodLiteral<"seek">;
61
+ position: z.ZodNumber;
62
+ }, z.core.$strict>, z.ZodObject<{
63
+ commandId: z.ZodString;
64
+ type: z.ZodLiteral<"next">;
65
+ }, z.core.$strict>, z.ZodObject<{
66
+ commandId: z.ZodString;
67
+ type: z.ZodLiteral<"stop">;
68
+ }, z.core.$strict>], "type">;
69
+ type BoardPlaybackCommand = z.infer<typeof BoardPlaybackCommandSchema>;
265
70
  //#endregion
266
- export { BOARD_DELETE_REASONS, BOARD_DOCUMENT_KIND, BOARD_EXTENSION, type BoardAssetRef, BoardCameraFocus, BoardCameraFocusParams, BoardCameraFocusParamsSchema, BoardCameraFocusSchema, BoardCameraState, BoardCameraStateSchema, type BoardCapability, BoardDeleteReason, BoardDiagnostic, type BoardEffect, BoardManifest, BoardManifestSchema, BoardMutationReceipt, BoardNodeInput, BoardNodeRecord, BoardOperation, BoardPlaybackSnapshot, BoardPlaybackStatus, BoardRecord, type BoardRenderCost, BoardTransactionOperation, BoardTransactionRecord, BoardTransactionsPage, BoardValidationResult, isBoardPath, parseBoardManifest, serializeBoardManifest };
71
+ export { BoardHistoryPage, BoardManifest, BoardManifestSchema, BoardPlaybackCommand, BoardPlaybackCommandSchema, BoardPlaybackSnapshot, BoardPlaybackStatus, BoardTransactionRecord, isBoardPath, parseBoardManifest, serializeBoardManifest };
@@ -1,15 +1,8 @@
1
- import { BoardConnectionSchema } from "./board-connection.js";
2
- import { BoardCompositionInputSchema } from "./board-composition.js";
3
- import { BoardEffectInputSchema } from "./board-effect.js";
4
- import { BoardAuthoringItemSchema, BoardItemPatchSchema, BoardSemanticMutationSchema } from "./board-authoring.js";
1
+ import { BoardIdSchema, BoardPatchSchema } from "./board-model.js";
5
2
  import { z } from "zod";
6
3
  //#region ../protocol/dist/board.js
7
4
  const BOARD_EXTENSION = ".board";
8
- const BOARD_DOCUMENT_KIND = "cohub.board";
9
5
  const BOARD_MANIFEST_KIND = "cohub.board.manifest";
10
- const idSchema = z.string().min(1).max(160);
11
- const jsonObjectSchema = z.record(z.string(), z.unknown());
12
- const finiteSchema = z.number().finite();
13
6
  const BoardManifestSchema = z.object({
14
7
  kind: z.literal(BOARD_MANIFEST_KIND),
15
8
  version: z.literal(1),
@@ -37,169 +30,78 @@ function parseBoardManifest(input) {
37
30
  function serializeBoardManifest(manifest) {
38
31
  return `${JSON.stringify(BoardManifestSchema.parse(manifest), null, 2)}\n`;
39
32
  }
40
- const BoardCameraStateSchema = z.object({
41
- centerX: finiteSchema,
42
- centerY: finiteSchema,
43
- zoom: finiteSchema.positive()
44
- });
45
- const BoardCameraFocusSchema = z.discriminatedUnion("type", [
46
- z.object({
47
- type: z.literal("rect"),
48
- rect: z.object({
49
- x: finiteSchema,
50
- y: finiteSchema,
51
- width: finiteSchema.positive(),
52
- height: finiteSchema.positive()
53
- })
54
- }),
55
- z.object({
56
- type: z.literal("item"),
57
- itemId: idSchema
58
- }),
59
- z.object({
60
- type: z.literal("items"),
61
- itemIds: z.array(idSchema).min(1).max(1e3)
62
- }),
63
- z.object({
64
- type: z.literal("frame"),
65
- frameId: idSchema
66
- })
67
- ]);
68
- const BoardCameraFocusParamsSchema = z.object({
69
- focus: BoardCameraFocusSchema,
70
- fit: z.enum(["contain", "cover"]).default("contain"),
71
- padding: finiteSchema.nonnegative().default(32),
72
- minZoom: finiteSchema.positive().optional(),
73
- maxZoom: finiteSchema.positive().optional()
74
- }).superRefine((value, context) => {
75
- if (value.minZoom !== void 0 && value.maxZoom !== void 0 && value.minZoom > value.maxZoom) context.addIssue({
76
- code: "custom",
77
- message: "minZoom must not exceed maxZoom",
78
- path: ["minZoom"]
79
- });
80
- });
81
- const BoardNodeInputSchema = z.object({
82
- nodeId: idSchema,
83
- type: z.string().min(1).max(40),
84
- parentId: idSchema.nullable(),
85
- orderKey: z.string().max(4096).nullable(),
86
- x: finiteSchema,
87
- y: finiteSchema,
88
- width: finiteSchema.positive(),
89
- height: finiteSchema.positive(),
90
- rotation: finiteSchema,
91
- refKind: z.string().max(40).nullable(),
92
- refPath: z.string().max(4096).nullable(),
93
- refUrl: z.string().max(4096).nullable(),
94
- view: jsonObjectSchema,
95
- style: jsonObjectSchema,
96
- data: jsonObjectSchema
97
- });
98
- const stripBoardServerFields = (value) => {
99
- if (!value || typeof value !== "object" || Array.isArray(value)) return value;
100
- const { boardId: _boardId, revision: _revision, ...input } = value;
101
- return input;
102
- };
103
- const BoardCreateEffectInputSchema = z.preprocess(stripBoardServerFields, BoardEffectInputSchema);
104
- const BoardCreateCompositionInputSchema = z.preprocess(stripBoardServerFields, BoardCompositionInputSchema);
105
- const BoardCreateInputSchema = z.object({
106
- path: z.string().min(1),
107
- /** Reused by clients when board creation is interrupted and retried. */
108
- mutationId: z.string().max(128).optional(),
109
- title: z.string().min(1).max(255).optional(),
110
- metadata: jsonObjectSchema.optional(),
111
- items: z.array(BoardAuthoringItemSchema).max(5e4).optional(),
112
- connections: z.array(BoardConnectionSchema).max(5e4).optional(),
113
- effects: z.array(BoardCreateEffectInputSchema).max(5e4).optional(),
114
- compositions: z.array(BoardCreateCompositionInputSchema).max(5e4).optional()
115
- });
116
- const jsonSchema = (schema) => z.toJSONSchema(schema);
117
- const authoringSchemaFactories = {
118
- item: () => jsonSchema(BoardAuthoringItemSchema),
119
- itemPatch: () => jsonSchema(BoardItemPatchSchema),
120
- mutation: () => jsonSchema(BoardSemanticMutationSchema),
121
- composition: () => jsonSchema(BoardCompositionInputSchema),
122
- effect: () => jsonSchema(BoardEffectInputSchema),
123
- create: () => jsonSchema(BoardCreateInputSchema)
124
- };
125
- /**
126
- * JSON Schemas for the semantic authoring surface. Each property is enumerable
127
- * for Object.keys/JSON.stringify, but generated only when that property is
128
- * requested. This keeps protocol imports cheap while capabilities still returns
129
- * the complete machine-readable schema object.
130
- */
131
- const BOARD_AUTHORING_SCHEMAS = {};
132
- for (const key of Object.keys(authoringSchemaFactories)) {
133
- let cached;
134
- Object.defineProperty(BOARD_AUTHORING_SCHEMAS, key, {
135
- enumerable: true,
136
- configurable: false,
137
- get() {
138
- cached ??= authoringSchemaFactories[key]();
139
- return cached;
140
- }
141
- });
33
+ function isBoardPath(path) {
34
+ return path.toLowerCase().endsWith(BOARD_EXTENSION);
142
35
  }
36
+ const BOARD_READ_SECTIONS = ["items", "animations"];
37
+ const rectSchema = z.object({
38
+ x: z.number().finite(),
39
+ y: z.number().finite(),
40
+ width: z.number().finite().positive(),
41
+ height: z.number().finite().positive()
42
+ }).strict();
143
43
  z.object({
144
- include: z.array(z.enum([
145
- "nodes",
146
- "connections",
147
- "effects",
148
- "compositions",
149
- "playback"
150
- ])).optional(),
151
- nodeIds: z.array(idSchema).max(5e4).optional(),
152
- connectionIds: z.array(idSchema).max(5e4).optional(),
153
- effectIds: z.array(idSchema).max(5e4).optional(),
154
- compositionIds: z.array(idSchema).max(5e4).optional(),
155
- viewport: z.object({
156
- x: finiteSchema,
157
- y: finiteSchema,
158
- width: finiteSchema.positive(),
159
- height: finiteSchema.positive()
160
- }).optional()
44
+ only: z.array(z.enum(BOARD_READ_SECTIONS)).optional(),
45
+ rect: rectSchema.optional(),
46
+ within: BoardIdSchema.optional(),
47
+ items: z.array(z.string().min(1)).max(5e4).optional(),
48
+ animations: z.array(z.string().min(1)).max(1e4).optional(),
49
+ limit: z.number().int().min(1).max(5e4).optional(),
50
+ cursor: z.string().min(1).optional()
51
+ }).strict().refine((read) => !(read.cursor && (read.rect || read.within)), {
52
+ path: ["cursor"],
53
+ message: "cursor pages by id, so it cannot be combined with rect or within"
161
54
  });
162
55
  z.object({
163
- /** Return transactions with `version < before`. Omit for the newest page. */
164
- before: z.number().int().positive().optional(),
165
- limit: z.number().int().min(1).max(500).default(200),
166
- /** Include the current rows on the newest page (default true). Tail refreshes turn this off. */
167
- snapshot: z.boolean().default(true)
168
- });
56
+ patch: BoardPatchSchema,
57
+ replace: z.boolean().default(false),
58
+ cascade: z.boolean().default(false),
59
+ dryRun: z.boolean().default(false),
60
+ baseVersion: z.number().int().nonnegative().optional(),
61
+ mutationId: z.string().min(1).max(160).optional(),
62
+ clientId: z.string().min(1).max(160).optional()
63
+ }).strict();
169
64
  z.object({
170
- compositionId: idSchema,
171
- /** Delay before the first local playback after opening the Board, in milliseconds. */
172
- delayMs: finiteSchema.nonnegative().default(0)
173
- });
65
+ path: z.string().min(1),
66
+ title: z.string().min(1).max(255).optional(),
67
+ document: BoardPatchSchema.optional(),
68
+ mutationId: z.string().max(160).optional()
69
+ }).strict();
70
+ z.object({
71
+ before: z.number().int().positive().optional(),
72
+ limit: z.number().int().min(1).max(500).default(200)
73
+ }).strict();
74
+ const commandId = z.string().min(1).max(160);
174
75
  z.discriminatedUnion("type", [
175
76
  z.object({
176
- commandId: idSchema,
77
+ commandId,
177
78
  type: z.literal("play"),
178
- compositionId: idSchema,
179
- position: finiteSchema.nonnegative().optional(),
180
- timeScale: finiteSchema.positive().max(4).optional(),
181
- shared: z.boolean().optional(),
182
- seed: idSchema.optional()
183
- }),
79
+ animationId: z.string().min(1),
80
+ position: z.number().finite().nonnegative().optional(),
81
+ timeScale: z.number().finite().positive().max(4).optional(),
82
+ seed: z.string().min(1).max(160).optional()
83
+ }).strict(),
84
+ z.object({
85
+ commandId,
86
+ type: z.literal("pause")
87
+ }).strict(),
184
88
  z.object({
185
- commandId: idSchema,
186
- type: z.literal("pause"),
187
- playbackId: z.string().uuid()
188
- }),
89
+ commandId,
90
+ type: z.literal("resume")
91
+ }).strict(),
189
92
  z.object({
190
- commandId: idSchema,
93
+ commandId,
191
94
  type: z.literal("seek"),
192
- playbackId: z.string().uuid(),
193
- position: finiteSchema.nonnegative()
194
- }),
95
+ position: z.number().finite().nonnegative()
96
+ }).strict(),
97
+ z.object({
98
+ commandId,
99
+ type: z.literal("next")
100
+ }).strict(),
195
101
  z.object({
196
- commandId: idSchema,
197
- type: z.literal("stop"),
198
- playbackId: z.string().uuid()
199
- })
102
+ commandId,
103
+ type: z.literal("stop")
104
+ }).strict()
200
105
  ]);
201
- function isBoardPath(path) {
202
- return path.toLowerCase().endsWith(BOARD_EXTENSION);
203
- }
204
106
  //#endregion
205
- export { BOARD_AUTHORING_SCHEMAS, BOARD_DOCUMENT_KIND, BOARD_EXTENSION, BOARD_MANIFEST_KIND, BoardCameraFocusParamsSchema, BoardCameraFocusSchema, BoardCameraStateSchema, BoardCreateInputSchema, BoardManifestSchema, BoardNodeInputSchema, InvalidBoardFileError, isBoardPath, parseBoardManifest, serializeBoardManifest };
107
+ export { BOARD_EXTENSION, BOARD_MANIFEST_KIND, BOARD_READ_SECTIONS, BoardManifestSchema, InvalidBoardFileError, isBoardPath, parseBoardManifest, serializeBoardManifest };
@@ -0,0 +1 @@
1
+ import "./index.js";
@@ -0,0 +1,2 @@
1
+ import "./actions.js";
2
+ import { z } from "zod";