@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 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 collections — `board` settings, `items`,
236
- and `animations`. Board targets accept a Board ID or a `.board` path. Every
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
@@ -1,16 +1,16 @@
1
1
  import type { BoardDocument, BoardExportRegion, BoardSceneItem } from "@neta-art/cohub/board";
2
- import type { BoardHeadlessExportFormat, BoardHeadlessFont, BoardHeadlessRenderer, BoardHeadlessTexture } from "@neta-art/cohub/board/headless";
3
- export declare function resolveBundledFonts(): BoardHeadlessFont[];
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(headless: BoardHeadlessRenderer, spaceId: string, items: readonly BoardSceneItem[], options?: {
10
+ export declare function loadBoardTextures(renderer: BoardNodeRenderer, spaceId: string, items: readonly BoardSceneItem[], options?: {
11
11
  concurrency?: number;
12
12
  }): Promise<{
13
- textures: Map<string, BoardHeadlessTexture>;
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: BoardHeadlessExportFormat;
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: BoardHeadlessExportFormat;
38
+ format: BoardNodeExportFormat;
39
39
  };
40
40
  export type BoardExportRunResult = {
41
41
  frames: BoardExportFrame[];
@@ -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, createBoardHeadlessRenderer, createBoardHeadlessSketchHost, exportBoardImageBytes, imageAssetKey, parseBoardDocument, planBoardExport, selectBoardExportAssets, } from "./board-kernel.js";
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(headless, spaceId, items, options = {}) {
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 headless.decodeImage(bytes, mimeType);
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 headless = await createBoardHeadlessRenderer({ fonts: resolveBundledFonts() });
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(headless, options.spaceId, plan.items);
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 headless.decodeImage(bytes, mimeType);
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 = createBoardHeadlessSketchHost(headless, {
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("Headless sketch host could not be created.");
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; headless video decoding is unavailable.`);
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(headless, document, {
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
- headless.destroy();
275
+ renderer.destroy();
276
276
  }
277
277
  }
278
278
  function describeWarning(warning) {
@@ -1,2 +1,2 @@
1
1
  export { boardDocumentAt, boardImageKeySource, buildBoardScene, imageAssetKey, parseBoardDocument, planBoardExport, selectBoardExportAssets, } from "@neta-art/cohub/board";
2
- export { createBoardHeadlessRenderer, createBoardHeadlessSketchHost, exportBoardImageBytes } from "@neta-art/cohub/board/headless";
2
+ export { createNodeBoardRenderer, createNodeBoardSketchHost, exportBoardImageBytes } from "@neta-art/cohub/board/export/node";