@zenuml/core 3.48.1 → 3.48.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.
@@ -12758,6 +12758,13 @@ Examples:
12758
12758
  zenuml --parse -i diagram.zenuml
12759
12759
  zenuml -i readme.md --md
12760
12760
  zenuml -i readme.md --md -e png
12761
+
12762
+ PNG output requires the optional Playwright runtime and a Chromium browser:
12763
+ npm install playwright-core
12764
+ npx playwright-core install chromium
12765
+
12766
+ To use an existing Chrome/Chromium binary:
12767
+ ZENUML_CHROMIUM_PATH=/path/to/chrome zenuml -i diagram.zenuml -o output.png
12761
12768
  `.trimStart();
12762
12769
  process.stdout.write(help);
12763
12770
  }
@@ -12899,11 +12906,42 @@ function loadConfigFile(filePath) {
12899
12906
  }
12900
12907
  }
12901
12908
  let _browser = null;
12909
+ function pngRuntimeHelp(detail) {
12910
+ return [
12911
+ detail,
12912
+ "",
12913
+ "PNG output requires Playwright's Chromium runtime.",
12914
+ "Install it with:",
12915
+ " npm install playwright-core",
12916
+ " npx playwright-core install chromium",
12917
+ "",
12918
+ "Or point ZenUML at an existing Chrome/Chromium binary:",
12919
+ " ZENUML_CHROMIUM_PATH=/path/to/chrome zenuml -i diagram.zenuml -o diagram.png"
12920
+ ].join("\n");
12921
+ }
12902
12922
  async function getPlaywrightBrowser() {
12903
12923
  if (_browser) return _browser;
12904
- const { chromium } = await import('playwright-core');
12905
- _browser = await chromium.launch();
12906
- return _browser;
12924
+ let playwright;
12925
+ try {
12926
+ playwright = await import('playwright-core');
12927
+ } catch (error) {
12928
+ throw new Error(
12929
+ pngRuntimeHelp(
12930
+ `Cannot load optional dependency "playwright-core": ${error instanceof Error ? error.message : String(error)}`
12931
+ )
12932
+ );
12933
+ }
12934
+ const executablePath = process.env["ZENUML_CHROMIUM_PATH"];
12935
+ try {
12936
+ _browser = await playwright.chromium.launch(executablePath ? { executablePath } : void 0);
12937
+ return _browser;
12938
+ } catch (error) {
12939
+ throw new Error(
12940
+ pngRuntimeHelp(
12941
+ `Cannot launch Chromium${executablePath ? ` at ${executablePath}` : ""}: ${error instanceof Error ? error.message : String(error)}`
12942
+ )
12943
+ );
12944
+ }
12907
12945
  }
12908
12946
  async function closeBrowser() {
12909
12947
  if (_browser) {