@diagrammo/dgmo 0.1.4 → 0.1.6

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
@@ -50,8 +50,8 @@ dgmo diagram.dgmo --theme dark --palette catppuccin
50
50
 
51
51
  | Option | Values | Default |
52
52
  |---|---|---|
53
- | `--theme` | `light`, `dark`, `transparent` | `light` |
54
- | `--palette` | `nord`, `solarized`, `catppuccin`, `rose-pine`, `gruvbox`, `tokyo-night`, `one-dark`, `bold` | `nord` |
53
+ | --theme | light, dark, transparent | light |
54
+ | --palette | nord, solarized, catppuccin, rose-pine, gruvbox, tokyo-night, one-dark, bold | nord |
55
55
 
56
56
  ## How it works
57
57
 
package/dist/cli.cjs CHANGED
@@ -30,6 +30,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  mod
31
31
  ));
32
32
 
33
+ // src/fonts.ts
34
+ var FONT_FAMILY, DEFAULT_FONT_NAME;
35
+ var init_fonts = __esm({
36
+ "src/fonts.ts"() {
37
+ "use strict";
38
+ FONT_FAMILY = "Inter, system-ui, Avenir, Helvetica, Arial, sans-serif";
39
+ DEFAULT_FONT_NAME = "Helvetica";
40
+ }
41
+ });
42
+
33
43
  // src/colors.ts
34
44
  function resolveColor(color, palette) {
35
45
  const lower = color.toLowerCase();
@@ -2124,10 +2134,7 @@ function renderSequenceDiagram(container, parsed, palette, isDark, _onNavigateTo
2124
2134
  participants.forEach((p, i) => {
2125
2135
  participantX.set(p.id, offsetX + i * PARTICIPANT_GAP);
2126
2136
  });
2127
- const svg = d3Selection.select(container).append("svg").attr("width", "100%").attr("height", totalHeight).attr("viewBox", `0 0 ${svgWidth} ${totalHeight}`).attr("preserveAspectRatio", "xMidYMin meet").attr("class", "sequence-diagram").style(
2128
- "font-family",
2129
- "Inter, system-ui, Avenir, Helvetica, Arial, sans-serif"
2130
- );
2137
+ const svg = d3Selection.select(container).append("svg").attr("width", "100%").attr("height", totalHeight).attr("viewBox", `0 0 ${svgWidth} ${totalHeight}`).attr("preserveAspectRatio", "xMidYMin meet").attr("class", "sequence-diagram").style("font-family", FONT_FAMILY);
2131
2138
  const defs = svg.append("defs");
2132
2139
  defs.append("marker").attr("id", "seq-arrowhead").attr("viewBox", `0 0 ${ARROWHEAD_SIZE} ${ARROWHEAD_SIZE}`).attr("refX", ARROWHEAD_SIZE).attr("refY", ARROWHEAD_SIZE / 2).attr("markerWidth", ARROWHEAD_SIZE).attr("markerHeight", ARROWHEAD_SIZE).attr("orient", "auto").append("polygon").attr(
2133
2140
  "points",
@@ -2449,6 +2456,7 @@ var init_renderer = __esm({
2449
2456
  "use strict";
2450
2457
  d3Selection = __toESM(require("d3-selection"), 1);
2451
2458
  init_colors();
2459
+ init_fonts();
2452
2460
  init_parser();
2453
2461
  PARTICIPANT_GAP = 160;
2454
2462
  PARTICIPANT_BOX_WIDTH = 120;
@@ -2480,6 +2488,7 @@ var d3Selection2 = __toESM(require("d3-selection"), 1);
2480
2488
  var d3Shape = __toESM(require("d3-shape"), 1);
2481
2489
  var d3Array = __toESM(require("d3-array"), 1);
2482
2490
  var import_d3_cloud = __toESM(require("d3-cloud"), 1);
2491
+ init_fonts();
2483
2492
  init_colors();
2484
2493
  init_palettes();
2485
2494
  var DEFAULT_CLOUD_OPTIONS = {
@@ -4445,8 +4454,8 @@ function renderWordCloudAsync(container, parsed, palette, _isDark) {
4445
4454
  "transform",
4446
4455
  `translate(${width / 2},${titleHeight + cloudHeight / 2})`
4447
4456
  );
4448
- (0, import_d3_cloud.default)().size([width, cloudHeight]).words(words.map((w) => ({ ...w, size: fontSize(w.weight) }))).padding(4).rotate(rotateFn).fontSize((d) => d.size).font("system-ui, -apple-system, sans-serif").on("end", (layoutWords) => {
4449
- g.selectAll("text").data(layoutWords).join("text").style("font-size", (d) => `${d.size}px`).style("font-family", "system-ui, -apple-system, sans-serif").style("font-weight", "600").style("fill", (_d, i) => colors[i % colors.length]).attr("text-anchor", "middle").attr(
4457
+ (0, import_d3_cloud.default)().size([width, cloudHeight]).words(words.map((w) => ({ ...w, size: fontSize(w.weight) }))).padding(4).rotate(rotateFn).fontSize((d) => d.size).font(FONT_FAMILY).on("end", (layoutWords) => {
4458
+ g.selectAll("text").data(layoutWords).join("text").style("font-size", (d) => `${d.size}px`).style("font-family", FONT_FAMILY).style("font-weight", "600").style("fill", (_d, i) => colors[i % colors.length]).attr("text-anchor", "middle").attr(
4450
4459
  "transform",
4451
4460
  (d) => `translate(${d.x},${d.y}) rotate(${d.rotate})`
4452
4461
  ).text((d) => d.text);
@@ -5050,6 +5059,7 @@ async function renderD3ForExport(content, theme, palette) {
5050
5059
  svgEl.style.background = "none";
5051
5060
  }
5052
5061
  svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
5062
+ svgEl.style.fontFamily = FONT_FAMILY;
5053
5063
  return svgEl.outerHTML;
5054
5064
  } finally {
5055
5065
  document.body.removeChild(container);
@@ -5058,6 +5068,7 @@ async function renderD3ForExport(content, theme, palette) {
5058
5068
 
5059
5069
  // src/cli.ts
5060
5070
  init_registry();
5071
+ init_fonts();
5061
5072
  var PALETTES = [
5062
5073
  "nord",
5063
5074
  "solarized",
@@ -5160,7 +5171,12 @@ function inferFormat(outputPath) {
5160
5171
  function svgToPng(svg, background) {
5161
5172
  const resvg = new import_resvg_js.Resvg(svg, {
5162
5173
  fitTo: { mode: "zoom", value: 2 },
5163
- ...background ? { background } : {}
5174
+ ...background ? { background } : {},
5175
+ font: {
5176
+ loadSystemFonts: true,
5177
+ defaultFontFamily: DEFAULT_FONT_NAME,
5178
+ sansSerifFamily: DEFAULT_FONT_NAME
5179
+ }
5164
5180
  });
5165
5181
  const rendered = resvg.render();
5166
5182
  return rendered.asPng();
package/dist/index.cjs CHANGED
@@ -1617,6 +1617,15 @@ var init_palettes = __esm({
1617
1617
  }
1618
1618
  });
1619
1619
 
1620
+ // src/fonts.ts
1621
+ var FONT_FAMILY;
1622
+ var init_fonts = __esm({
1623
+ "src/fonts.ts"() {
1624
+ "use strict";
1625
+ FONT_FAMILY = "Inter, system-ui, Avenir, Helvetica, Arial, sans-serif";
1626
+ }
1627
+ });
1628
+
1620
1629
  // src/sequence/renderer.ts
1621
1630
  var renderer_exports = {};
1622
1631
  __export(renderer_exports, {
@@ -2124,10 +2133,7 @@ function renderSequenceDiagram(container, parsed, palette, isDark, _onNavigateTo
2124
2133
  participants.forEach((p, i) => {
2125
2134
  participantX.set(p.id, offsetX + i * PARTICIPANT_GAP);
2126
2135
  });
2127
- const svg = d3Selection.select(container).append("svg").attr("width", "100%").attr("height", totalHeight).attr("viewBox", `0 0 ${svgWidth} ${totalHeight}`).attr("preserveAspectRatio", "xMidYMin meet").attr("class", "sequence-diagram").style(
2128
- "font-family",
2129
- "Inter, system-ui, Avenir, Helvetica, Arial, sans-serif"
2130
- );
2136
+ const svg = d3Selection.select(container).append("svg").attr("width", "100%").attr("height", totalHeight).attr("viewBox", `0 0 ${svgWidth} ${totalHeight}`).attr("preserveAspectRatio", "xMidYMin meet").attr("class", "sequence-diagram").style("font-family", FONT_FAMILY);
2131
2137
  const defs = svg.append("defs");
2132
2138
  defs.append("marker").attr("id", "seq-arrowhead").attr("viewBox", `0 0 ${ARROWHEAD_SIZE} ${ARROWHEAD_SIZE}`).attr("refX", ARROWHEAD_SIZE).attr("refY", ARROWHEAD_SIZE / 2).attr("markerWidth", ARROWHEAD_SIZE).attr("markerHeight", ARROWHEAD_SIZE).attr("orient", "auto").append("polygon").attr(
2133
2139
  "points",
@@ -2449,6 +2455,7 @@ var init_renderer = __esm({
2449
2455
  "use strict";
2450
2456
  d3Selection = __toESM(require("d3-selection"), 1);
2451
2457
  init_colors();
2458
+ init_fonts();
2452
2459
  init_parser();
2453
2460
  PARTICIPANT_GAP = 160;
2454
2461
  PARTICIPANT_BOX_WIDTH = 120;
@@ -3163,6 +3170,7 @@ function buildChartJsConfig(parsed, palette, _isDark) {
3163
3170
  }
3164
3171
 
3165
3172
  // src/echarts.ts
3173
+ init_fonts();
3166
3174
  init_colors();
3167
3175
  init_palettes();
3168
3176
  function parseEChart(content, palette) {
@@ -3397,7 +3405,7 @@ function buildEChartsOption(parsed, palette, _isDark) {
3397
3405
  color: textColor,
3398
3406
  fontSize: 18,
3399
3407
  fontWeight: "bold",
3400
- fontFamily: "system-ui, -apple-system, sans-serif"
3408
+ fontFamily: FONT_FAMILY
3401
3409
  }
3402
3410
  } : void 0;
3403
3411
  const tooltipTheme = {
@@ -4045,6 +4053,7 @@ var d3Selection2 = __toESM(require("d3-selection"), 1);
4045
4053
  var d3Shape = __toESM(require("d3-shape"), 1);
4046
4054
  var d3Array = __toESM(require("d3-array"), 1);
4047
4055
  var import_d3_cloud = __toESM(require("d3-cloud"), 1);
4056
+ init_fonts();
4048
4057
  init_colors();
4049
4058
  init_palettes();
4050
4059
  var DEFAULT_CLOUD_OPTIONS = {
@@ -6003,8 +6012,8 @@ function renderWordCloud(container, parsed, palette, _isDark, onClickItem) {
6003
6012
  "transform",
6004
6013
  `translate(${width / 2},${titleHeight + cloudHeight / 2})`
6005
6014
  );
6006
- (0, import_d3_cloud.default)().size([width, cloudHeight]).words(words.map((w) => ({ ...w, size: fontSize(w.weight) }))).padding(4).rotate(rotateFn).fontSize((d) => d.size).font("system-ui, -apple-system, sans-serif").on("end", (layoutWords) => {
6007
- g.selectAll("text").data(layoutWords).join("text").style("font-size", (d) => `${d.size}px`).style("font-family", "system-ui, -apple-system, sans-serif").style("font-weight", "600").style("fill", (_d, i) => colors[i % colors.length]).style(
6015
+ (0, import_d3_cloud.default)().size([width, cloudHeight]).words(words.map((w) => ({ ...w, size: fontSize(w.weight) }))).padding(4).rotate(rotateFn).fontSize((d) => d.size).font(FONT_FAMILY).on("end", (layoutWords) => {
6016
+ g.selectAll("text").data(layoutWords).join("text").style("font-size", (d) => `${d.size}px`).style("font-family", FONT_FAMILY).style("font-weight", "600").style("fill", (_d, i) => colors[i % colors.length]).style(
6008
6017
  "cursor",
6009
6018
  (d) => onClickItem && d.lineNumber ? "pointer" : "default"
6010
6019
  ).attr("text-anchor", "middle").attr(
@@ -6053,8 +6062,8 @@ function renderWordCloudAsync(container, parsed, palette, _isDark) {
6053
6062
  "transform",
6054
6063
  `translate(${width / 2},${titleHeight + cloudHeight / 2})`
6055
6064
  );
6056
- (0, import_d3_cloud.default)().size([width, cloudHeight]).words(words.map((w) => ({ ...w, size: fontSize(w.weight) }))).padding(4).rotate(rotateFn).fontSize((d) => d.size).font("system-ui, -apple-system, sans-serif").on("end", (layoutWords) => {
6057
- g.selectAll("text").data(layoutWords).join("text").style("font-size", (d) => `${d.size}px`).style("font-family", "system-ui, -apple-system, sans-serif").style("font-weight", "600").style("fill", (_d, i) => colors[i % colors.length]).attr("text-anchor", "middle").attr(
6065
+ (0, import_d3_cloud.default)().size([width, cloudHeight]).words(words.map((w) => ({ ...w, size: fontSize(w.weight) }))).padding(4).rotate(rotateFn).fontSize((d) => d.size).font(FONT_FAMILY).on("end", (layoutWords) => {
6066
+ g.selectAll("text").data(layoutWords).join("text").style("font-size", (d) => `${d.size}px`).style("font-family", FONT_FAMILY).style("font-weight", "600").style("fill", (_d, i) => colors[i % colors.length]).attr("text-anchor", "middle").attr(
6058
6067
  "transform",
6059
6068
  (d) => `translate(${d.x},${d.y}) rotate(${d.rotate})`
6060
6069
  ).text((d) => d.text);
@@ -6658,6 +6667,7 @@ async function renderD3ForExport(content, theme, palette) {
6658
6667
  svgEl.style.background = "none";
6659
6668
  }
6660
6669
  svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
6670
+ svgEl.style.fontFamily = FONT_FAMILY;
6661
6671
  return svgEl.outerHTML;
6662
6672
  } finally {
6663
6673
  document.body.removeChild(container);