@zenuml/core 3.49.6 → 3.50.1

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.
@@ -9518,10 +9518,6 @@ RetContext.prototype.From = function() {
9518
9518
  return this.asyncMessage()?.From() || this.returnAsyncMessage()?.From() || this.ClosestAncestorStat().Origin();
9519
9519
  };
9520
9520
 
9521
- antlr4.ParserRuleContext.prototype.Key = function() {
9522
- return `${this.start.start}:${this.stop.stop}`;
9523
- };
9524
-
9525
9521
  const seqParser = sequenceParser;
9526
9522
  const StatContext = seqParser.StatContext;
9527
9523
  antlr4.ParserRuleContext.prototype.ClosestAncestorStat = function() {
@@ -9650,10 +9646,6 @@ antlr4.ParserRuleContext.prototype.getComment = function () {
9650
9646
  );
9651
9647
  };
9652
9648
 
9653
- antlr4.ParserRuleContext.prototype.returnedValue = function () {
9654
- return this.braceBlock().block().ret().value();
9655
- };
9656
-
9657
9649
  sequenceParser.ProgContext;
9658
9650
  const RootContext = rootContext;
9659
9651
  sequenceParser.GroupContext;
@@ -13223,7 +13215,10 @@ function expandInputs(inputs) {
13223
13215
  }
13224
13216
  const glob = new Bun.Glob(input);
13225
13217
  const matches = [];
13226
- for (const match of glob.scanSync({ cwd: process.cwd(), onlyFiles: true })) {
13218
+ for (const match of glob.scanSync({
13219
+ cwd: process.cwd(),
13220
+ onlyFiles: true
13221
+ })) {
13227
13222
  matches.push(match);
13228
13223
  }
13229
13224
  if (matches.length === 0) {
@@ -13242,7 +13237,17 @@ function isDirectory(p) {
13242
13237
  }
13243
13238
  }
13244
13239
  function parseArgs(argv) {
13245
- const args = { inputs: [], check: false, parse: false, json: false, quiet: false, help: false, version: false, md: false, watch: false };
13240
+ const args = {
13241
+ inputs: [],
13242
+ check: false,
13243
+ parse: false,
13244
+ json: false,
13245
+ quiet: false,
13246
+ help: false,
13247
+ version: false,
13248
+ md: false,
13249
+ watch: false
13250
+ };
13246
13251
  let i = 0;
13247
13252
  while (i < argv.length) {
13248
13253
  const arg = argv[i];
@@ -13306,9 +13311,11 @@ function parseArgs(argv) {
13306
13311
  args.watch = true;
13307
13312
  break;
13308
13313
  default:
13309
- process.stderr.write(`Unknown option: ${arg}
13314
+ process.stderr.write(
13315
+ `Unknown option: ${arg}
13310
13316
  Run "zenuml --help" for usage.
13311
- `);
13317
+ `
13318
+ );
13312
13319
  process.exit(1);
13313
13320
  }
13314
13321
  i++;
@@ -13361,7 +13368,9 @@ async function getPlaywrightBrowser() {
13361
13368
  }
13362
13369
  const executablePath = process.env["ZENUML_CHROMIUM_PATH"];
13363
13370
  try {
13364
- _browser = await playwright.chromium.launch(executablePath ? { executablePath } : void 0);
13371
+ _browser = await playwright.chromium.launch(
13372
+ executablePath ? { executablePath } : void 0
13373
+ );
13365
13374
  return _browser;
13366
13375
  } catch (error) {
13367
13376
  throw new Error(
@@ -13402,6 +13411,54 @@ async function rasterizeToPng(svgString, svgWidth, svgHeight, scale) {
13402
13411
  function getRuleNames(ctx) {
13403
13412
  return ctx?.parser?.ruleNames;
13404
13413
  }
13414
+ function isFacadeNode(node) {
13415
+ return !!node && node.symbol === void 0 && !node.parser && !!node._doc && typeof node.constructor?.name === "string" && node.constructor.name.endsWith("Context");
13416
+ }
13417
+ function facadeRuleName(className) {
13418
+ const base = className.endsWith("Context") ? className.slice(0, -"Context".length) : className;
13419
+ return base.charAt(0).toLowerCase() + base.slice(1);
13420
+ }
13421
+ function serializeFacadeNode(node) {
13422
+ const result = {
13423
+ type: "rule",
13424
+ ruleName: facadeRuleName(node.constructor.name)
13425
+ };
13426
+ const ruleChildren = node.children ?? [];
13427
+ const childSpans = ruleChildren.map((c) => ({
13428
+ c,
13429
+ start: c.start?.start ?? null,
13430
+ end: c.stop?.stop ?? null
13431
+ // inclusive
13432
+ }));
13433
+ const items = [];
13434
+ for (const cs of childSpans) {
13435
+ if (cs.start !== null) {
13436
+ items.push({ off: cs.start, node: serializeParseTree(cs.c) });
13437
+ }
13438
+ }
13439
+ const nodeStart = node.start?.start;
13440
+ const nodeStop = node.stop?.stop;
13441
+ if (nodeStart !== void 0 && nodeStop !== null && nodeStop !== void 0) {
13442
+ for (const leaf of node._doc.leaves) {
13443
+ if (leaf.offset < nodeStart) continue;
13444
+ if (leaf.offset > nodeStop) break;
13445
+ if (leaf.hidden) continue;
13446
+ const covered = childSpans.some(
13447
+ (cs) => cs.start !== null && cs.end !== null && leaf.offset >= cs.start && leaf.offset <= cs.end
13448
+ );
13449
+ if (covered) continue;
13450
+ items.push({
13451
+ off: leaf.offset,
13452
+ node: { type: "terminal", text: leaf.text }
13453
+ });
13454
+ }
13455
+ }
13456
+ items.sort((a, b) => a.off - b.off);
13457
+ if (items.length > 0) {
13458
+ result.children = items.map((it) => it.node);
13459
+ }
13460
+ return result;
13461
+ }
13405
13462
  function serializeParseTree(node) {
13406
13463
  if (!node) return { type: "null" };
13407
13464
  if (node.symbol !== void 0) {
@@ -13410,6 +13467,9 @@ function serializeParseTree(node) {
13410
13467
  text: node.getText()
13411
13468
  };
13412
13469
  }
13470
+ if (isFacadeNode(node)) {
13471
+ return serializeFacadeNode(node);
13472
+ }
13413
13473
  const ruleNames = getRuleNames(node);
13414
13474
  const ruleName = ruleNames && node.ruleIndex !== void 0 ? ruleNames[node.ruleIndex] : void 0;
13415
13475
  const result = {
@@ -13501,7 +13561,9 @@ async function main() {
13501
13561
  process.exit(1);
13502
13562
  }
13503
13563
  if (expandedInputs.includes("-")) {
13504
- process.stderr.write("Error: --watch is incompatible with stdin input.\n");
13564
+ process.stderr.write(
13565
+ "Error: --watch is incompatible with stdin input.\n"
13566
+ );
13505
13567
  process.exit(1);
13506
13568
  }
13507
13569
  }
@@ -13521,8 +13583,10 @@ async function main() {
13521
13583
  }
13522
13584
  for (const e of r.errors) {
13523
13585
  const prefix = expandedInputs.length > 1 ? " " : "";
13524
- process.stderr.write(`${prefix}line ${e.line}, col ${e.column}: ${e.msg}
13525
- `);
13586
+ process.stderr.write(
13587
+ `${prefix}line ${e.line}, col ${e.column}: ${e.msg}
13588
+ `
13589
+ );
13526
13590
  }
13527
13591
  }
13528
13592
  }
@@ -13532,7 +13596,9 @@ async function main() {
13532
13596
  }
13533
13597
  if (args.parse) {
13534
13598
  if (expandedInputs.length > 1) {
13535
- process.stderr.write("Error: --parse supports only a single input file.\n");
13599
+ process.stderr.write(
13600
+ "Error: --parse supports only a single input file.\n"
13601
+ );
13536
13602
  process.exit(1);
13537
13603
  }
13538
13604
  const input = expandedInputs[0];
@@ -13558,20 +13624,22 @@ async function main() {
13558
13624
  process.stdout.write(JSON.stringify(ast, null, 2) + "\n");
13559
13625
  process.exit(0);
13560
13626
  }
13561
- const isMdMode = args.md || expandedInputs.some(
13562
- (f) => f !== "-" && /\.(?:md|markdown)$/i.test(f)
13563
- );
13627
+ const isMdMode = args.md || expandedInputs.some((f) => f !== "-" && /\.(?:md|markdown)$/i.test(f));
13564
13628
  if (isMdMode) {
13565
13629
  if (expandedInputs.length > 1) {
13566
- process.stderr.write("Error: --md mode supports only a single input file.\n");
13630
+ process.stderr.write(
13631
+ "Error: --md mode supports only a single input file.\n"
13632
+ );
13567
13633
  process.exit(1);
13568
13634
  }
13569
13635
  const inputArg = expandedInputs[0];
13570
13636
  if (args.md && inputArg !== "-") {
13571
13637
  const ext = extname(inputArg).toLowerCase();
13572
13638
  if (ext !== ".md" && ext !== ".markdown") {
13573
- process.stderr.write(`Error: --md flag requires a .md or .markdown input file, got: ${inputArg}
13574
- `);
13639
+ process.stderr.write(
13640
+ `Error: --md flag requires a .md or .markdown input file, got: ${inputArg}
13641
+ `
13642
+ );
13575
13643
  process.exit(1);
13576
13644
  }
13577
13645
  }
@@ -13585,8 +13653,10 @@ async function main() {
13585
13653
  }
13586
13654
  const effectiveFormat = args.outputFormat ?? "svg";
13587
13655
  if (effectiveFormat !== "svg" && effectiveFormat !== "png") {
13588
- process.stderr.write(`Error: Unsupported output format: "${effectiveFormat}". Use "svg" or "png".
13589
- `);
13656
+ process.stderr.write(
13657
+ `Error: Unsupported output format: "${effectiveFormat}". Use "svg" or "png".
13658
+ `
13659
+ );
13590
13660
  process.exit(1);
13591
13661
  }
13592
13662
  let imageDir;
@@ -13646,13 +13716,20 @@ async function main() {
13646
13716
  svgWidth = result.width;
13647
13717
  svgHeight = result.height;
13648
13718
  } catch (err) {
13649
- process.stderr.write(`Error: Failed to render zenuml block ${block.index}: ${err.message}
13650
- `);
13719
+ process.stderr.write(
13720
+ `Error: Failed to render zenuml block ${block.index}: ${err.message}
13721
+ `
13722
+ );
13651
13723
  process.exit(1);
13652
13724
  }
13653
13725
  mkdirSync(imageDir, { recursive: true });
13654
13726
  if (effectiveFormat === "png") {
13655
- const pngBuffer = await rasterizeToPng(svg, svgWidth, svgHeight, effectiveScale);
13727
+ const pngBuffer = await rasterizeToPng(
13728
+ svg,
13729
+ svgWidth,
13730
+ svgHeight,
13731
+ effectiveScale
13732
+ );
13656
13733
  writeFileSync(imageFilePath, pngBuffer);
13657
13734
  } else {
13658
13735
  writeFileSync(imageFilePath, svg, "utf-8");
@@ -13694,11 +13771,14 @@ async function main() {
13694
13771
  const cfg = loadConfigFile(args.configFile);
13695
13772
  if (typeof cfg.scale === "number") configScale = cfg.scale;
13696
13773
  if (typeof cfg.theme === "string") configTheme = cfg.theme;
13697
- if (typeof cfg.outputFormat === "string") configOutputFormat = cfg.outputFormat;
13774
+ if (typeof cfg.outputFormat === "string")
13775
+ configOutputFormat = cfg.outputFormat;
13698
13776
  }
13699
13777
  const multipleInputs = expandedInputs.length > 1;
13700
13778
  if (multipleInputs && args.output && args.output !== "-" && !isDirectory(resolve(args.output))) {
13701
- process.stderr.write("Error: -o must be a directory when multiple input files are provided.\n");
13779
+ process.stderr.write(
13780
+ "Error: -o must be a directory when multiple input files are provided.\n"
13781
+ );
13702
13782
  process.exit(1);
13703
13783
  }
13704
13784
  if (args.watch) {
@@ -13717,7 +13797,9 @@ async function main() {
13717
13797
  }
13718
13798
  const effectiveFormat = args.outputFormat ?? "svg";
13719
13799
  if (effectiveFormat !== "svg" && effectiveFormat !== "png") {
13720
- throw new Error(`Unsupported output format: "${effectiveFormat}". Use "svg" or "png".`);
13800
+ throw new Error(
13801
+ `Unsupported output format: "${effectiveFormat}". Use "svg" or "png".`
13802
+ );
13721
13803
  }
13722
13804
  let mdOutputPath;
13723
13805
  let imageDir;
@@ -13749,7 +13831,12 @@ async function main() {
13749
13831
  const { svg, width: svgWidth, height: svgHeight } = result;
13750
13832
  mkdirSync(imageDir, { recursive: true });
13751
13833
  if (effectiveFormat === "png") {
13752
- const pngBuffer = await rasterizeToPng(svg, svgWidth, svgHeight, effectiveScale);
13834
+ const pngBuffer = await rasterizeToPng(
13835
+ svg,
13836
+ svgWidth,
13837
+ svgHeight,
13838
+ effectiveScale
13839
+ );
13753
13840
  writeFileSync(imageFilePath, pngBuffer);
13754
13841
  } else {
13755
13842
  writeFileSync(imageFilePath, svg, "utf-8");
@@ -13775,7 +13862,9 @@ async function main() {
13775
13862
  writeFileSync(mdOutputPath, outputMd, "utf-8");
13776
13863
  }
13777
13864
  };
13778
- const hasMdInputs = expandedInputs.some((f) => /\.(?:md|markdown)$/i.test(f));
13865
+ const hasMdInputs = expandedInputs.some(
13866
+ (f) => /\.(?:md|markdown)$/i.test(f)
13867
+ );
13779
13868
  const renderMdFnForWatch = hasMdInputs ? renderMdForWatch : void 0;
13780
13869
  const watchHandle = await startWatchMode(
13781
13870
  expandedInputs,
@@ -13828,7 +13917,9 @@ async function renderOneFile(inputArg, args, config) {
13828
13917
  const autoFormatFromExt = outputPath !== "-" && extname(outputPath).toLowerCase() === ".png" ? "png" : void 0;
13829
13918
  const effectiveFormat = args.outputFormat ?? config.configOutputFormat ?? autoFormatFromExt ?? "svg";
13830
13919
  if (effectiveFormat !== "svg" && effectiveFormat !== "png") {
13831
- throw new Error(`Unsupported output format: "${effectiveFormat}". Use "svg" or "png".`);
13920
+ throw new Error(
13921
+ `Unsupported output format: "${effectiveFormat}". Use "svg" or "png".`
13922
+ );
13832
13923
  }
13833
13924
  const effectiveScale = args.scale ?? config.configScale ?? 2;
13834
13925
  const effectiveTheme = args.theme ?? config.configTheme;
@@ -13870,7 +13961,12 @@ async function renderOneFile(inputArg, args, config) {
13870
13961
  mkdirSync(dir, { recursive: true });
13871
13962
  }
13872
13963
  if (effectiveFormat === "png") {
13873
- const pngBuffer = await rasterizeToPng(svg, svgWidth, svgHeight, effectiveScale);
13964
+ const pngBuffer = await rasterizeToPng(
13965
+ svg,
13966
+ svgWidth,
13967
+ svgHeight,
13968
+ effectiveScale
13969
+ );
13874
13970
  if (finalOutputPath === "-") {
13875
13971
  process.stdout.write(pngBuffer);
13876
13972
  } else {