@neta-art/cohub-cli 10.14.0 → 10.15.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.
@@ -1,5 +1,7 @@
1
1
  import type { BoardDocument, BoardExportRegion, BoardSceneItem, BoardThemeId } from "@neta-art/cohub/board";
2
2
  import type { BoardNodeExportFormat, BoardNodeFont, BoardNodeTexture } from "@neta-art/cohub/board/export/node";
3
+ import type { BoardScriptHost } from "@neta-art/cohub/board/render";
4
+ import { createClient } from "./client.js";
3
5
  import { type BoardExportDecodeImage } from "./board-export-resources.js";
4
6
  export declare function resolveBundledFonts(): BoardNodeFont[];
5
7
  export type BoardExportSource = {
@@ -33,6 +35,10 @@ export declare function loadBoardTextures(images: {
33
35
  }): Promise<{
34
36
  textures: Map<string, BoardNodeTexture>;
35
37
  } & Record<"failed" | "unavailable" | "omitted", string[]>>;
38
+ export declare function readSpaceFileBytes(client: ReturnType<typeof createClient>, spaceId: string, path: string): Promise<{
39
+ bytes: Uint8Array;
40
+ mimeType: string;
41
+ }>;
36
42
  export type BoardExportRunOptions = {
37
43
  spaceId: string;
38
44
  target: string;
@@ -51,6 +57,7 @@ export type BoardExportRunOptions = {
51
57
  height: number;
52
58
  };
53
59
  document?: BoardDocument;
60
+ scripts?: BoardScriptHost;
54
61
  signal?: AbortSignal;
55
62
  imageMemoryMiB?: number;
56
63
  onPlan?: (plan: {
@@ -152,7 +152,7 @@ async function fetchBoardPicture(client, spaceId, source, item, edge) {
152
152
  }
153
153
  return source.kind === "url" ? downloadPublicImage(source.value) : readSpaceFileBytes(client, spaceId, source.value);
154
154
  }
155
- async function readSpaceFileBytes(client, spaceId, path) {
155
+ export async function readSpaceFileBytes(client, spaceId, path) {
156
156
  const { blob, mimeType } = await client.space(spaceId).files.download(path);
157
157
  return { bytes: new Uint8Array(await blob.arrayBuffer()), mimeType };
158
158
  }
@@ -321,7 +321,7 @@ export async function runBoardExport(options) {
321
321
  warnings.push("The board background image could not be loaded; the fallback color was exported.");
322
322
  }
323
323
  }
324
- if (hasBoardScripts(document))
324
+ if (!options.scripts && hasBoardScripts(document))
325
325
  scriptHost = createNodeBoardScriptHost(renderer, {
326
326
  concurrency: 2,
327
327
  readModule: async (src) => {
@@ -382,7 +382,7 @@ export async function runBoardExport(options) {
382
382
  ...theme,
383
383
  background: options.background,
384
384
  textures,
385
- scripts: scriptHost ?? undefined,
385
+ scripts: options.scripts ?? scriptHost ?? undefined,
386
386
  backgroundTexture,
387
387
  assetKey,
388
388
  format: options.format,
@@ -2,3 +2,4 @@ export { BOARD_SCRIPT_DRAWING_EXAMPLE, hasBoardScripts, boardAssetKey, boardAsse
2
2
  export { prepareBoardExport } from "@neta-art/cohub/board/export";
3
3
  export { boardRenderTheme, createBoardRenderSampler, inspectBoardScene, inspectBoardItems, measureBoardText } from "@neta-art/cohub/board/render";
4
4
  export { createNodeBoardRenderer, createNodeBoardScriptHost, exportBoardImageBytes } from "@neta-art/cohub/board/export/node";
5
+ export { createBoardScriptHarness } from "@neta-art/cohub/board/testing";