@oomol-lab/open-flow 0.1.0-beta.82 → 0.1.0-beta.83

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,6 +1,14 @@
1
1
  import type { WorkflowFile } from '../../common/flow-workflowFile.js';
2
2
  import type { UiLanguage } from '../../common/localization.js';
3
+ export type FlowPngLayout = 'original' | 'compact';
4
+ export declare const flowPngAspectRatios: readonly ['auto', '1:1', '4:3', '3:4', '16:9', '9:16'];
5
+ export type FlowPngAspectRatio = (typeof flowPngAspectRatios)[number];
6
+ export declare function getFlowPngAspectRatio(value?: FlowPngAspectRatio): readonly [number, number] | undefined;
3
7
  export interface FlowPngOptions {
8
+ /** Compact applies to vertical workflows; horizontal exports preserve saved positions. */
9
+ readonly layout?: FlowPngLayout;
10
+ /** Ratio of the complete image, including its frame; defaults to the content bounds. */
11
+ readonly aspectRatio?: FlowPngAspectRatio;
4
12
  readonly language?: UiLanguage;
5
13
  readonly dark?: boolean;
6
14
  readonly frame?: boolean;
@@ -3,7 +3,7 @@ import type { WorkflowFile } from '../../common/flow-workflowFile.js';
3
3
  import type { FlowPngOptions, RenderResponse } from '../common/png.js';
4
4
  import { Buffer } from 'node:buffer';
5
5
  export type { WorkflowFile } from '../../common/flow-workflowFile.js';
6
- export type { FlowPngOptions } from '../common/png.js';
6
+ export type { FlowPngAspectRatio, FlowPngLayout, FlowPngOptions } from '../common/png.js';
7
7
  export interface FlowPngResult extends Omit<RenderResponse, 'dataUrl'> {
8
8
  readonly buffer: Buffer;
9
9
  }
@@ -9451,10 +9451,27 @@ function decodeWorkflowFile(value) {
9451
9451
  };
9452
9452
  }
9453
9453
  //#endregion
9454
+ //#region src/render/common/png.ts
9455
+ var flowPngAspectRatios = [
9456
+ "auto",
9457
+ "1:1",
9458
+ "4:3",
9459
+ "3:4",
9460
+ "16:9",
9461
+ "9:16"
9462
+ ];
9463
+ function getFlowPngAspectRatio(value) {
9464
+ if (value == null || value === "auto") return void 0;
9465
+ if (!flowPngAspectRatios.includes(value)) throw new TypeError("Unsupported PNG canvas aspect ratio.");
9466
+ const [width, height] = value.split(":").map(Number);
9467
+ return [width, height];
9468
+ }
9469
+ //#endregion
9454
9470
  //#region src/render/node/index.ts
9455
9471
  /** Render a workflow file without launching or closing the caller's browser. */
9456
9472
  async function flowToPng(browser, workflow, options = {}) {
9457
9473
  const file = decodeWorkflowFile(workflow);
9474
+ getFlowPngAspectRatio(options.aspectRatio);
9458
9475
  const packageRoot = dirname(createRequire(import.meta.url).resolve("@oomol-lab/open-flow/package.json"));
9459
9476
  const [script, style] = await Promise.all([readFile(join(packageRoot, "dist/render/browser/runtime.js"), "utf8"), readFile(join(packageRoot, "dist/render/browser/runtime.css"), "utf8")]);
9460
9477
  const context = await browser.newContext({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oomol-lab/open-flow",
3
- "version": "0.1.0-beta.82",
3
+ "version": "0.1.0-beta.83",
4
4
  "description": "TypeScript contracts and Browser runtime for Open Flow.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {