@neta-art/cohub-cli 9.1.0 → 9.1.2
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 +2 -2
- package/dist/board-export.d.ts +6 -6
- package/dist/board-export.js +11 -11
- package/dist/board-kernel.d.ts +1 -1
- package/dist/board-kernel.js +623 -412
- package/dist/commands/me.js +2 -0
- package/dist/commands/spaces.js +3 -0
- package/dist/network-error.d.ts +3 -0
- package/dist/network-error.js +22 -0
- package/dist/output.js +4 -9
- package/dist/runtime/connection.js +2 -1
- package/dist/runtime/harness.js +3 -6
- package/dist/runtime/model-catalog.d.ts +8 -0
- package/dist/runtime/model-catalog.js +50 -2
- package/dist/runtime/native/execution.js +4 -3
- package/dist/safe-remote-image.d.ts +5 -1
- package/dist/safe-remote-image.js +16 -8
- package/dist/session-status.d.ts +6 -0
- package/dist/session-status.js +14 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -232,8 +232,8 @@ cohub -s <spaceId> spaces activity 365 --json
|
|
|
232
232
|
|
|
233
233
|
## Boards
|
|
234
234
|
|
|
235
|
-
A Board is one JSON document with three
|
|
236
|
-
and `animations
|
|
235
|
+
A Board is one JSON document with three parts — `board` settings, an `items` map,
|
|
236
|
+
and an `animations` map. Board targets accept a Board ID or a `.board` path. Every
|
|
237
237
|
command supports `-h`, and the global `--json` makes the output machine-readable:
|
|
238
238
|
|
|
239
239
|
```bash
|
package/dist/board-export.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { BoardDocument, BoardExportRegion, BoardSceneItem } from "@neta-art/cohub/board";
|
|
2
|
-
import type {
|
|
3
|
-
export declare function resolveBundledFonts():
|
|
2
|
+
import type { BoardNodeExportFormat, BoardNodeFont, BoardNodeRenderer, BoardNodeTexture } from "@neta-art/cohub/board/export/node";
|
|
3
|
+
export declare function resolveBundledFonts(): BoardNodeFont[];
|
|
4
4
|
export type BoardExportSource = {
|
|
5
5
|
document: BoardDocument;
|
|
6
6
|
boardId: string;
|
|
7
7
|
title: string | null;
|
|
8
8
|
};
|
|
9
9
|
export declare function loadBoardDocument(spaceId: string, target: string): Promise<BoardExportSource>;
|
|
10
|
-
export declare function loadBoardTextures(
|
|
10
|
+
export declare function loadBoardTextures(renderer: BoardNodeRenderer, spaceId: string, items: readonly BoardSceneItem[], options?: {
|
|
11
11
|
concurrency?: number;
|
|
12
12
|
}): Promise<{
|
|
13
|
-
textures: Map<string,
|
|
13
|
+
textures: Map<string, BoardNodeTexture>;
|
|
14
14
|
failed: string[];
|
|
15
15
|
omitted: string[];
|
|
16
16
|
}>;
|
|
@@ -24,7 +24,7 @@ export type BoardExportRunOptions = {
|
|
|
24
24
|
padding?: number;
|
|
25
25
|
colorScheme: "dark" | "light";
|
|
26
26
|
background: "paper" | "transparent";
|
|
27
|
-
format:
|
|
27
|
+
format: BoardNodeExportFormat;
|
|
28
28
|
quality?: number;
|
|
29
29
|
withImages: boolean;
|
|
30
30
|
};
|
|
@@ -35,7 +35,7 @@ export type BoardExportFrame = {
|
|
|
35
35
|
height: number;
|
|
36
36
|
scale: number;
|
|
37
37
|
itemCount: number;
|
|
38
|
-
format:
|
|
38
|
+
format: BoardNodeExportFormat;
|
|
39
39
|
};
|
|
40
40
|
export type BoardExportRunResult = {
|
|
41
41
|
frames: BoardExportFrame[];
|
package/dist/board-export.js
CHANGED
|
@@ -7,7 +7,7 @@ import { dirname, join } from "node:path";
|
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { tmpdir } from "node:os";
|
|
9
9
|
const execFile = promisify(execFileCallback);
|
|
10
|
-
import { boardDocumentAt, boardImageKeySource, buildBoardScene,
|
|
10
|
+
import { boardDocumentAt, boardImageKeySource, buildBoardScene, createNodeBoardRenderer, createNodeBoardSketchHost, exportBoardImageBytes, imageAssetKey, parseBoardDocument, planBoardExport, selectBoardExportAssets, } from "./board-kernel.js";
|
|
11
11
|
import { resolveBoardId } from "./board-command-support.js";
|
|
12
12
|
import { BOARD_EXPORT_FONTS } from "./board-fonts.js";
|
|
13
13
|
import { createClient } from "./client.js";
|
|
@@ -45,7 +45,7 @@ export async function loadBoardDocument(spaceId, target) {
|
|
|
45
45
|
throw new Error(`Board ${result.id} could not be read: ${parsed.diagnostics[0]?.path}: ${parsed.diagnostics[0]?.message}`);
|
|
46
46
|
return { document: parsed.document, boardId: result.id, title: result.title };
|
|
47
47
|
}
|
|
48
|
-
export async function loadBoardTextures(
|
|
48
|
+
export async function loadBoardTextures(renderer, spaceId, items, options = {}) {
|
|
49
49
|
const selection = selectBoardExportAssets([...items], imageAssetKey);
|
|
50
50
|
const textures = new Map();
|
|
51
51
|
const failed = [];
|
|
@@ -66,7 +66,7 @@ export async function loadBoardTextures(headless, spaceId, items, options = {})
|
|
|
66
66
|
const { bytes, mimeType } = source.kind === "file"
|
|
67
67
|
? await readSpaceFileBytes(client, spaceId, source.value)
|
|
68
68
|
: await downloadPublicImage(source.value);
|
|
69
|
-
const texture = await
|
|
69
|
+
const texture = await renderer.decodeImage(bytes, mimeType);
|
|
70
70
|
textures.set(key, texture);
|
|
71
71
|
}
|
|
72
72
|
catch {
|
|
@@ -161,7 +161,7 @@ export async function runBoardExport(options) {
|
|
|
161
161
|
});
|
|
162
162
|
if (!plan)
|
|
163
163
|
return null;
|
|
164
|
-
const
|
|
164
|
+
const renderer = await createNodeBoardRenderer({ fonts: resolveBundledFonts() });
|
|
165
165
|
let sketchHost = null;
|
|
166
166
|
try {
|
|
167
167
|
const warnings = [];
|
|
@@ -169,7 +169,7 @@ export async function runBoardExport(options) {
|
|
|
169
169
|
let backgroundTexture;
|
|
170
170
|
let omittedKeys = new Set();
|
|
171
171
|
if (options.withImages) {
|
|
172
|
-
const loaded = await loadBoardTextures(
|
|
172
|
+
const loaded = await loadBoardTextures(renderer, options.spaceId, plan.items);
|
|
173
173
|
textures = loaded.textures;
|
|
174
174
|
omittedKeys = new Set(loaded.omitted);
|
|
175
175
|
if (loaded.failed.length > 0) {
|
|
@@ -186,14 +186,14 @@ export async function runBoardExport(options) {
|
|
|
186
186
|
declaredBackground.imageUrl) {
|
|
187
187
|
try {
|
|
188
188
|
const { bytes, mimeType } = await downloadPublicImage(declaredBackground.imageUrl);
|
|
189
|
-
backgroundTexture = await
|
|
189
|
+
backgroundTexture = await renderer.decodeImage(bytes, mimeType);
|
|
190
190
|
}
|
|
191
191
|
catch {
|
|
192
192
|
warnings.push("The board background image could not be loaded; the fallback color was exported.");
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
const videoCount = plan.items.filter((item) => item.type === "video").length;
|
|
196
|
-
sketchHost =
|
|
196
|
+
sketchHost = createNodeBoardSketchHost(renderer, {
|
|
197
197
|
readModule: async (src) => {
|
|
198
198
|
const { bytes } = await readSpaceFileBytes(createClient(), options.spaceId, src);
|
|
199
199
|
return new TextDecoder().decode(bytes);
|
|
@@ -202,7 +202,7 @@ export async function runBoardExport(options) {
|
|
|
202
202
|
const region = times.length > 1 ? { kind: "rect", rect: plan.world } : options.region;
|
|
203
203
|
const host = sketchHost;
|
|
204
204
|
if (!host)
|
|
205
|
-
throw new Error("
|
|
205
|
+
throw new Error("Node sketch host could not be created.");
|
|
206
206
|
const sketchVariants = new Map();
|
|
207
207
|
for (const time of times) {
|
|
208
208
|
const sketchPlan = planBoardExport({
|
|
@@ -220,7 +220,7 @@ export async function runBoardExport(options) {
|
|
|
220
220
|
}
|
|
221
221
|
await Promise.all([...sketchVariants.values()].map((variant) => host.prepare([variant.item], variant.times, plan.scale)));
|
|
222
222
|
if (videoCount > 0) {
|
|
223
|
-
warnings.push(`${videoCount} video preview${videoCount === 1 ? " was" : "s were"} drawn as placeholders;
|
|
223
|
+
warnings.push(`${videoCount} video preview${videoCount === 1 ? " was" : "s were"} drawn as placeholders; video decoding is unavailable in Node.`);
|
|
224
224
|
}
|
|
225
225
|
const backgroundImage = backgroundTexture
|
|
226
226
|
? { texture: backgroundTexture, fit: declaredBackground.fit ?? "cover", position: "center", opacity: declaredBackground.opacity ?? 1 }
|
|
@@ -234,7 +234,7 @@ export async function runBoardExport(options) {
|
|
|
234
234
|
const frames = [];
|
|
235
235
|
const reported = new Set();
|
|
236
236
|
for (const time of times) {
|
|
237
|
-
const result = exportBoardImageBytes(
|
|
237
|
+
const result = exportBoardImageBytes(renderer, document, {
|
|
238
238
|
...(time === null ? {} : { at: { ...(options.animation ? { animation: options.animation } : {}), time } }),
|
|
239
239
|
region,
|
|
240
240
|
scale: options.scale,
|
|
@@ -272,7 +272,7 @@ export async function runBoardExport(options) {
|
|
|
272
272
|
}
|
|
273
273
|
finally {
|
|
274
274
|
sketchHost?.destroy();
|
|
275
|
-
|
|
275
|
+
renderer.destroy();
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
function describeWarning(warning) {
|
package/dist/board-kernel.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { boardDocumentAt, boardImageKeySource, buildBoardScene, imageAssetKey, parseBoardDocument, planBoardExport, selectBoardExportAssets, } from "@neta-art/cohub/board";
|
|
2
|
-
export {
|
|
2
|
+
export { createNodeBoardRenderer, createNodeBoardSketchHost, exportBoardImageBytes } from "@neta-art/cohub/board/export/node";
|