@neta-art/cohub 8.23.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.
- package/dist/board/animation.d.ts +57 -181
- package/dist/board/animation.js +374 -220
- package/dist/board/core/arrow-geometry.d.ts +33 -18
- package/dist/board/core/arrow-geometry.js +283 -52
- package/dist/board/core/draw-geometry.d.ts +22 -36
- package/dist/board/core/draw-geometry.js +148 -85
- package/dist/board/core/export-assets.d.ts +3 -6
- package/dist/board/core/export-assets.js +0 -2
- package/dist/board/core/export-plan.d.ts +12 -63
- package/dist/board/core/export-plan.js +55 -94
- package/dist/board/core/palette.d.ts +4 -21
- package/dist/board/core/palette.js +8 -13
- package/dist/board/core/scene.d.ts +33 -0
- package/dist/board/core/scene.js +302 -0
- package/dist/board/core/shape-definition.d.ts +12 -24
- package/dist/board/core/shape-definition.js +0 -19
- package/dist/board/core/shape-types.d.ts +6 -120
- package/dist/board/core/shape-types.js +5 -5
- package/dist/board/core/text-metrics.d.ts +8 -11
- package/dist/board/core/text-metrics.js +5 -34
- package/dist/board/core/tool-styles.d.ts +6 -16
- package/dist/board/core/tool-styles.js +17 -25
- package/dist/board/export/index.d.ts +10 -17
- package/dist/board/export/index.js +22 -21
- package/dist/board/export/scene.d.ts +10 -16
- package/dist/board/export/scene.js +17 -30
- package/dist/board/geometry.d.ts +27 -56
- package/dist/board/geometry.js +7 -67
- package/dist/board/headless/index.d.ts +7 -27
- package/dist/board/headless/index.js +20 -19
- package/dist/board/headless/sketch.d.ts +19 -0
- package/dist/board/headless/sketch.js +146 -0
- package/dist/board/image-key.d.ts +2 -12
- package/dist/board/image-key.js +3 -13
- package/dist/board/index.d.ts +18 -20
- package/dist/board/index.js +17 -17
- package/dist/board/media-playback.d.ts +3 -6
- package/dist/board/media-playback.js +6 -6
- package/dist/board/presets.d.ts +150 -0
- package/dist/board/presets.js +226 -0
- package/dist/board/render/board-background.d.ts +5 -3
- package/dist/board/render/board-background.js +8 -7
- package/dist/board/render/clip.d.ts +14 -0
- package/dist/board/render/clip.js +47 -0
- package/dist/board/render/index.d.ts +8 -5
- package/dist/board/render/index.js +7 -4
- package/dist/board/render/media-interaction.d.ts +4 -5
- package/dist/board/render/media-interaction.js +1 -2
- package/dist/board/render/palette.d.ts +6 -2
- package/dist/board/render/palette.js +7 -1
- package/dist/board/render/renderers/arrow-card-renderer.js +69 -71
- package/dist/board/render/renderers/audio-card-renderer.js +3 -3
- package/dist/board/render/renderers/base-card-renderer.d.ts +6 -17
- package/dist/board/render/renderers/base-card-renderer.js +1 -24
- package/dist/board/render/renderers/board-renderer-registry.d.ts +20 -50
- package/dist/board/render/renderers/board-renderer-registry.js +6 -7
- package/dist/board/render/renderers/draw-card-renderer.js +89 -56
- package/dist/board/render/renderers/effect-card-renderer.d.ts +6 -0
- package/dist/board/render/renderers/effect-card-renderer.js +197 -0
- package/dist/board/render/renderers/far-plate.d.ts +4 -21
- package/dist/board/render/renderers/far-plate.js +15 -34
- package/dist/board/render/renderers/file-card-renderer.d.ts +4 -25
- package/dist/board/render/renderers/file-card-renderer.js +8 -58
- package/dist/board/render/renderers/frame-card-renderer.js +28 -28
- package/dist/board/render/renderers/image-card-renderer.d.ts +4 -3
- package/dist/board/render/renderers/image-card-renderer.js +0 -9
- package/dist/board/render/renderers/shape-card-renderer.d.ts +9 -0
- package/dist/board/render/renderers/shape-card-renderer.js +240 -0
- package/dist/board/render/renderers/sketch-card-renderer.d.ts +5 -0
- package/dist/board/render/renderers/sketch-card-renderer.js +98 -0
- package/dist/board/render/renderers/task-card-renderer.d.ts +0 -1
- package/dist/board/render/renderers/task-card-renderer.js +14 -16
- package/dist/board/render/renderers/text-card-renderer.d.ts +1 -3
- package/dist/board/render/renderers/text-card-renderer.js +56 -46
- package/dist/board/render/renderers/unknown-card-renderer.js +4 -10
- package/dist/board/render/renderers/video-card-renderer.d.ts +4 -2
- package/dist/board/render/renderers/video-card-renderer.js +2 -1
- package/dist/board/render/sketch-host.d.ts +14 -0
- package/dist/board/render/sketch-host.js +216 -0
- package/dist/board/render/stroke.d.ts +12 -0
- package/dist/board/render/stroke.js +90 -0
- package/dist/board/render/text-measurement.d.ts +6 -26
- package/dist/board/render/text-measurement.js +11 -30
- package/dist/board/replay.d.ts +6 -31
- package/dist/board/replay.js +45 -203
- package/dist/board/runtime/board-player.d.ts +24 -0
- package/dist/board/runtime/board-player.js +161 -0
- package/dist/board/task.d.ts +2 -10
- package/dist/board/task.js +1 -10
- package/dist/chunks/environment.d.ts +2296 -3864
- package/dist/chunks/host-bridge.d.ts +253 -0
- package/dist/chunks/http.d.ts +238 -58
- package/dist/chunks/http.js +1061 -1034
- package/dist/chunks/transport.js +113 -59
- package/dist/chunks/websocket.d.ts +1 -1
- package/dist/chunks/websocket.js +1 -1
- package/dist/host-bridge.d.ts +54 -0
- package/dist/host-bridge.js +322 -0
- package/dist/http.d.ts +3 -3
- package/dist/index.d.ts +76 -193
- package/dist/index.js +2037 -1191
- package/dist/protocol/dist/board-constants.d.ts +1 -29
- package/dist/protocol/dist/board-constants.js +2 -115
- package/dist/protocol/dist/board-layout.d.ts +59 -0
- package/dist/protocol/dist/board-layout.js +482 -0
- package/dist/protocol/dist/board-model.d.ts +2052 -0
- package/dist/protocol/dist/board-model.js +592 -0
- package/dist/protocol/dist/board-patch.d.ts +86 -0
- package/dist/protocol/dist/board-patch.js +734 -0
- package/dist/protocol/dist/board-schema.d.ts +33 -0
- package/dist/protocol/dist/board-schema.js +59 -0
- package/dist/protocol/dist/board-upgrade.d.ts +1 -0
- package/dist/protocol/dist/board-url.d.ts +1 -3
- package/dist/protocol/dist/board-url.js +2 -2
- package/dist/protocol/dist/board.d.ts +37 -232
- package/dist/protocol/dist/board.js +62 -160
- package/dist/protocol/dist/display/actions.d.ts +1 -0
- package/dist/protocol/dist/display/index.d.ts +2 -0
- package/dist/protocol/dist/index.d.ts +11 -12
- package/dist/protocol/dist/model/metrics.d.ts +2 -0
- package/dist/protocol/dist/model/session.d.ts +2 -1
- package/dist/protocol/dist/realtime/types.d.ts +2 -2
- package/dist/protocol/dist/runtime/index.d.ts +1 -0
- package/dist/space-picker.d.ts +1 -0
- package/dist/space-picker.js +1 -0
- package/dist/types.d.ts +2 -5
- package/package.json +9 -1
- package/dist/board/core/connections.d.ts +0 -108
- package/dist/board/core/connections.js +0 -455
- package/dist/board/mutation.d.ts +0 -6
- package/dist/board/mutation.js +0 -14
- package/dist/board/render/connection-layer.d.ts +0 -53
- package/dist/board/render/connection-layer.js +0 -375
- package/dist/board/render/renderers/geo-card-renderer.d.ts +0 -5
- package/dist/board/render/renderers/geo-card-renderer.js +0 -127
- package/dist/board/semantic-document.d.ts +0 -37
- package/dist/board/semantic-document.js +0 -288
- package/dist/board/semantic-mutation.d.ts +0 -10
- package/dist/board/semantic-mutation.js +0 -209
- package/dist/protocol/dist/board-animation.js +0 -34
- package/dist/protocol/dist/board-authoring.d.ts +0 -1326
- package/dist/protocol/dist/board-authoring.js +0 -302
- package/dist/protocol/dist/board-capability-registry.d.ts +0 -2
- package/dist/protocol/dist/board-capability-registry.js +0 -123
- package/dist/protocol/dist/board-codec.d.ts +0 -3
- package/dist/protocol/dist/board-codec.js +0 -383
- package/dist/protocol/dist/board-composition.d.ts +0 -383
- package/dist/protocol/dist/board-composition.js +0 -310
- package/dist/protocol/dist/board-connection.d.ts +0 -317
- package/dist/protocol/dist/board-connection.js +0 -219
- package/dist/protocol/dist/board-document.d.ts +0 -1566
- package/dist/protocol/dist/board-document.js +0 -456
- package/dist/protocol/dist/board-effect.d.ts +0 -96
- package/dist/protocol/dist/board-effect.js +0 -54
- package/dist/protocol/dist/board-geometry.d.ts +0 -15
- package/dist/protocol/dist/board-geometry.js +0 -137
- package/dist/protocol/dist/board-node.d.ts +0 -8
- package/dist/protocol/dist/board-node.js +0 -252
- /package/dist/protocol/dist/{board-animation.d.ts → host-bridge.d.ts} +0 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { boardAnimationTime, compileBoardAnimations, evaluateBoardAnimations } from "../animation.js";
|
|
2
|
+
import { boardPresetTracks, isBoardPresetName } from "../presets.js";
|
|
3
|
+
//#region src/board/runtime/board-player.ts
|
|
4
|
+
const ENTER_ANIMATION = "\0enter";
|
|
5
|
+
const ENTER_STAGGER_MS = 45;
|
|
6
|
+
const ENTER_MAX_ITEMS = 80;
|
|
7
|
+
function playbackTimeAt(playback, document, now) {
|
|
8
|
+
const animation = document.animations[playback.animationId];
|
|
9
|
+
if (!animation || playback.status === "stopped") return null;
|
|
10
|
+
if (playback.status !== "playing") return Math.min(playback.position, animation.duration);
|
|
11
|
+
let position = playback.position + Math.max(0, now - playback.effectiveAt) * playback.timeScale;
|
|
12
|
+
const pause = animation.markers.find((marker) => marker.pause && marker.at > playback.position && marker.at <= position);
|
|
13
|
+
if (pause) return pause.at;
|
|
14
|
+
if (animation.loop || animation.play === "always") return animation.duration > 0 ? position % animation.duration : 0;
|
|
15
|
+
position = Math.min(position, animation.duration);
|
|
16
|
+
return animation.end === "reset" && position >= animation.duration ? null : position;
|
|
17
|
+
}
|
|
18
|
+
function createBoardPlayer(options = {}) {
|
|
19
|
+
let document = null;
|
|
20
|
+
let compiled = null;
|
|
21
|
+
let openedAt = performance.now();
|
|
22
|
+
let entrance = null;
|
|
23
|
+
function compile(next) {
|
|
24
|
+
if (document?.animations === next.animations && document?.items === next.items && compiled) return compiled;
|
|
25
|
+
document = next;
|
|
26
|
+
let source = next;
|
|
27
|
+
const preset = next.board.enter?.preset;
|
|
28
|
+
if (entrance && preset && isBoardPresetName(preset)) {
|
|
29
|
+
const tracks = boardPresetTracks(preset, {
|
|
30
|
+
targets: entrance.ids,
|
|
31
|
+
stagger: ENTER_STAGGER_MS,
|
|
32
|
+
...next.board.enter?.duration ? { duration: next.board.enter.duration } : {}
|
|
33
|
+
});
|
|
34
|
+
source = {
|
|
35
|
+
...next,
|
|
36
|
+
animations: {
|
|
37
|
+
...next.animations,
|
|
38
|
+
[ENTER_ANIMATION]: {
|
|
39
|
+
duration: entrance.duration,
|
|
40
|
+
play: "manual",
|
|
41
|
+
delay: 0,
|
|
42
|
+
loop: false,
|
|
43
|
+
end: "reset",
|
|
44
|
+
markers: [],
|
|
45
|
+
tracks
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
compiled = compileBoardAnimations(source);
|
|
51
|
+
return compiled;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
reset() {
|
|
55
|
+
openedAt = performance.now();
|
|
56
|
+
entrance = null;
|
|
57
|
+
compiled = null;
|
|
58
|
+
},
|
|
59
|
+
enter(ids, current) {
|
|
60
|
+
if (!current.board.enter?.preset || ids.length === 0 || ids.length > ENTER_MAX_ITEMS) return;
|
|
61
|
+
const duration = (current.board.enter?.duration ?? 700) + ENTER_STAGGER_MS * ids.length;
|
|
62
|
+
entrance = {
|
|
63
|
+
ids: [...ids],
|
|
64
|
+
startedAt: performance.now(),
|
|
65
|
+
duration
|
|
66
|
+
};
|
|
67
|
+
compiled = null;
|
|
68
|
+
},
|
|
69
|
+
frame(current, playback, now, wallNow, exclude) {
|
|
70
|
+
if (entrance && now - entrance.startedAt > entrance.duration) {
|
|
71
|
+
entrance = null;
|
|
72
|
+
compiled = null;
|
|
73
|
+
}
|
|
74
|
+
const animations = compile(current);
|
|
75
|
+
const times = /* @__PURE__ */ new Map();
|
|
76
|
+
let running = false;
|
|
77
|
+
for (const [id, animation] of animations.animations) {
|
|
78
|
+
if (id === exclude) continue;
|
|
79
|
+
const header = animation.header;
|
|
80
|
+
if (header.play === "always") {
|
|
81
|
+
times.set(id, boardAnimationTime(header, wallNow) ?? 0);
|
|
82
|
+
running = true;
|
|
83
|
+
} else if (header.play === "auto") {
|
|
84
|
+
const time = boardAnimationTime(header, now - openedAt);
|
|
85
|
+
if (time !== null) times.set(id, time);
|
|
86
|
+
if (time !== null && time < header.duration) running = true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
let playbackTime = null;
|
|
90
|
+
if (playback && playback.animationId !== exclude) {
|
|
91
|
+
playbackTime = playbackTimeAt(playback, current, wallNow);
|
|
92
|
+
if (playbackTime !== null) {
|
|
93
|
+
times.set(playback.animationId, playbackTime);
|
|
94
|
+
if (playback.status === "playing") running = true;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (entrance) {
|
|
98
|
+
times.set(ENTER_ANIMATION, now - entrance.startedAt);
|
|
99
|
+
running = true;
|
|
100
|
+
}
|
|
101
|
+
const evaluation = times.size ? evaluateBoardAnimations(animations, times, options) : null;
|
|
102
|
+
return {
|
|
103
|
+
items: evaluation?.items ?? /* @__PURE__ */ new Map(),
|
|
104
|
+
camera: evaluation?.camera ?? {},
|
|
105
|
+
time: playbackTime ?? now - openedAt,
|
|
106
|
+
playbackTime,
|
|
107
|
+
running
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function nextLocalPlayback(current, command, document, now = Date.now()) {
|
|
113
|
+
const position = current ? playbackTimeAt(current, document, now) ?? 0 : 0;
|
|
114
|
+
const base = {
|
|
115
|
+
effectiveAt: now,
|
|
116
|
+
commandId: command.commandId,
|
|
117
|
+
revision: (current?.revision ?? 0) + 1
|
|
118
|
+
};
|
|
119
|
+
switch (command.type) {
|
|
120
|
+
case "play": return {
|
|
121
|
+
playbackId: crypto.randomUUID(),
|
|
122
|
+
animationId: command.animationId,
|
|
123
|
+
animationRevision: 0,
|
|
124
|
+
status: "playing",
|
|
125
|
+
position: command.position ?? 0,
|
|
126
|
+
timeScale: command.timeScale ?? 1,
|
|
127
|
+
seed: command.seed ?? "local",
|
|
128
|
+
...base
|
|
129
|
+
};
|
|
130
|
+
case "pause": return current ? {
|
|
131
|
+
...current,
|
|
132
|
+
...base,
|
|
133
|
+
status: "paused",
|
|
134
|
+
position
|
|
135
|
+
} : null;
|
|
136
|
+
case "resume": return current ? {
|
|
137
|
+
...current,
|
|
138
|
+
...base,
|
|
139
|
+
status: "playing",
|
|
140
|
+
position
|
|
141
|
+
} : null;
|
|
142
|
+
case "seek": return current ? {
|
|
143
|
+
...current,
|
|
144
|
+
...base,
|
|
145
|
+
position: command.position
|
|
146
|
+
} : null;
|
|
147
|
+
case "next": {
|
|
148
|
+
if (!current) return null;
|
|
149
|
+
const after = (document.animations[current.animationId]?.markers ?? []).find((marker) => marker.pause && marker.at > position + 1);
|
|
150
|
+
return {
|
|
151
|
+
...current,
|
|
152
|
+
...base,
|
|
153
|
+
status: "playing",
|
|
154
|
+
position: after ? position + 1 : position
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
case "stop": return null;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
export { createBoardPlayer, nextLocalPlayback, playbackTimeAt };
|
package/dist/board/task.d.ts
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import { BoardTaskArtifact, BoardTaskSnapshot } from "../protocol/dist/board-
|
|
1
|
+
import { BoardTaskArtifact, BoardTaskSnapshot } from "../protocol/dist/board-model.js";
|
|
2
|
+
import "../protocol/dist/index.js";
|
|
2
3
|
import { TaskRunRecord } from "../types.js";
|
|
3
4
|
//#region src/board/task.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Group provider blocks into user-facing works. A cover belongs to the media
|
|
6
|
-
* it depicts (see `generationCovers`) instead of becoming a competing image.
|
|
7
|
-
*/
|
|
8
5
|
declare function taskArtifacts(blocks: Record<string, unknown>[]): BoardTaskArtifact[];
|
|
9
|
-
/** Highest-value artifact first, with provider order as the stable final tie. */
|
|
10
6
|
declare function rankedTaskArtifacts(artifacts: readonly BoardTaskArtifact[]): BoardTaskArtifact[];
|
|
11
7
|
declare function featuredTaskArtifact(artifacts: readonly BoardTaskArtifact[]): BoardTaskArtifact | undefined;
|
|
12
8
|
declare function taskArtifactPreviewUrl(artifact: BoardTaskArtifact | undefined): string | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Project an authoritative TaskRun into a small, replaceable Board display cache.
|
|
15
|
-
* Raw payloads, complete results and inline media are never copied into the Board.
|
|
16
|
-
*/
|
|
17
9
|
declare function taskRunToBoardTaskSnapshot(run: TaskRunRecord): BoardTaskSnapshot;
|
|
18
10
|
//#endregion
|
|
19
11
|
export { featuredTaskArtifact, rankedTaskArtifacts, taskArtifactPreviewUrl, taskArtifacts, taskRunToBoardTaskSnapshot };
|
package/dist/board/task.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../protocol/dist/board-
|
|
1
|
+
import "../protocol/dist/board-model.js";
|
|
2
2
|
import { blockDurationMs, blockIdentity, blockMimeType, blockNaturalSize, blockPreviewUrl, blockText, blockTitle, blockUrl, cleanExcerpt, generationCovers, generationOutput, generationPrompt, taskData } from "../generation-blocks.js";
|
|
3
3
|
//#region src/board/task.ts
|
|
4
4
|
function artifactId(base, used, suffix) {
|
|
@@ -12,10 +12,6 @@ function artifactId(base, used, suffix) {
|
|
|
12
12
|
used.add(candidate);
|
|
13
13
|
return candidate;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Group provider blocks into user-facing works. A cover belongs to the media
|
|
17
|
-
* it depicts (see `generationCovers`) instead of becoming a competing image.
|
|
18
|
-
*/
|
|
19
15
|
function taskArtifacts(blocks) {
|
|
20
16
|
const covers = new Map([...generationCovers(blocks)].filter(([media]) => Boolean(blockUrl(blocks[media] ?? {}))));
|
|
21
17
|
const coverIndexes = new Set(covers.values());
|
|
@@ -123,7 +119,6 @@ function compareArtifacts(a, b) {
|
|
|
123
119
|
}
|
|
124
120
|
return 0;
|
|
125
121
|
}
|
|
126
|
-
/** Highest-value artifact first, with provider order as the stable final tie. */
|
|
127
122
|
function rankedTaskArtifacts(artifacts) {
|
|
128
123
|
return artifacts.map((artifact, index) => ({
|
|
129
124
|
artifact,
|
|
@@ -142,10 +137,6 @@ function taskArtifactPreviewUrl(artifact) {
|
|
|
142
137
|
function taskTypeTitle(taskType) {
|
|
143
138
|
return taskType.replace(/[._-]+/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
|
|
144
139
|
}
|
|
145
|
-
/**
|
|
146
|
-
* Project an authoritative TaskRun into a small, replaceable Board display cache.
|
|
147
|
-
* Raw payloads, complete results and inline media are never copied into the Board.
|
|
148
|
-
*/
|
|
149
140
|
function taskRunToBoardTaskSnapshot(run) {
|
|
150
141
|
const data = taskData(run);
|
|
151
142
|
const blocks = run.taskType === "generation" ? generationOutput(run) : [];
|