sketchmark 0.2.2 → 0.2.4

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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EAKV,MAAM,UAAU,CAAC;AAqZlB,wBAAgB,SAAS,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAmB1E;AAoID,wBAAgB,MAAM,CAAC,EAAE,EAAE,UAAU,GAAG,UAAU,CA+NjD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EAKV,MAAM,UAAU,CAAC;AAoZlB,wBAAgB,SAAS,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAmB1E;AAoID,wBAAgB,MAAM,CAAC,EAAE,EAAE,UAAU,GAAG,UAAU,CA+NjD"}
@@ -13,7 +13,7 @@ export declare function chartLayout(c: {
13
13
  y: number;
14
14
  w: number;
15
15
  h: number;
16
- title?: string;
16
+ label?: string;
17
17
  }): ChartLayout;
18
18
  export interface BarLineSeries {
19
19
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderer/svg/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,UAAU,EAMX,MAAM,aAAa,CAAC;AA0drB,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAClC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,WAAW,CACzB,EAAE,EAAE,UAAU,EACd,SAAS,EAAE,WAAW,GAAG,aAAa,EACtC,OAAO,GAAE,kBAAuB,GAC/B,aAAa,CAisBf;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAKtD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderer/svg/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,UAAU,EAMX,MAAM,aAAa,CAAC;AA0drB,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAClC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,WAAW,CACzB,EAAE,EAAE,UAAU,EACd,SAAS,EAAE,WAAW,GAAG,aAAa,EACtC,OAAO,GAAE,kBAAuB,GAC/B,aAAa,CAgsBf;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAKtD"}
@@ -84,7 +84,7 @@ export interface SceneNote {
84
84
  export interface SceneChart {
85
85
  id: string;
86
86
  chartType: string;
87
- title?: string;
87
+ label?: string;
88
88
  data: {
89
89
  headers: string[];
90
90
  rows: (string | number)[][];
@@ -851,7 +851,7 @@ var AIDiagram = (function (exports) {
851
851
  kind: "chart",
852
852
  id,
853
853
  chartType: chartType.replace("-chart", ""),
854
- title: props.title,
854
+ label: props.label ?? props.title,
855
855
  data: { headers, rows },
856
856
  width: props.width ? parseFloat(props.width) : undefined,
857
857
  height: props.height ? parseFloat(props.height) : undefined,
@@ -1343,7 +1343,7 @@ var AIDiagram = (function (exports) {
1343
1343
  return {
1344
1344
  id: c.id,
1345
1345
  chartType: c.chartType,
1346
- title: c.title,
1346
+ label: c.label,
1347
1347
  data: c.data,
1348
1348
  style: { ...ast.styles[c.id], ...themeStyle, ...c.style },
1349
1349
  x: 0,
@@ -1541,9 +1541,8 @@ var AIDiagram = (function (exports) {
1541
1541
  const nData = rows.filter((r) => r.kind === "data").length;
1542
1542
  t.h = labelH + nHeader * headerH + nData * rowH;
1543
1543
  }
1544
- function sizeChart(c) {
1545
- c.w = c.w || 320;
1546
- c.h = c.h || 240;
1544
+ function sizeChart(_c) {
1545
+ // defaults already applied in buildSceneGraph
1547
1546
  }
1548
1547
  function sizeMarkdown(m) {
1549
1548
  const pad = Number(m.style?.padding ?? 16);
@@ -2078,7 +2077,7 @@ var AIDiagram = (function (exports) {
2078
2077
  '#7F77DD', '#D4537E', '#639922', '#E24B4A',
2079
2078
  ];
2080
2079
  function chartLayout(c) {
2081
- const titleH = c.title ? 24 : 8;
2080
+ const titleH = c.label ? 24 : 8;
2082
2081
  const padL = 44, padR = 12, padB = 28, padT = 6;
2083
2082
  const pw = c.w - padL - padR;
2084
2083
  const ph = c.h - titleH - padT - padB;
@@ -2266,17 +2265,17 @@ var AIDiagram = (function (exports) {
2266
2265
  ...(s.strokeDash ? { strokeLineDash: s.strokeDash } : {}),
2267
2266
  }));
2268
2267
  // Title
2269
- if (c.title) {
2270
- cg.appendChild(mkT(c.title, c.x + c.w / 2, c.y + 14, cFontSize, cFontWeight, lc, 'middle', cFont));
2268
+ if (c.label) {
2269
+ cg.appendChild(mkT(c.label, c.x + c.w / 2, c.y + 14, cFontSize, cFontWeight, lc, 'middle', cFont));
2271
2270
  }
2272
2271
  const { px, py, pw, ph, cx, cy } = chartLayout(c);
2273
2272
  // ── Pie / Donut ──────────────────────────────────────────
2274
2273
  if (c.chartType === 'pie' || c.chartType === 'donut') {
2275
2274
  const { segments, total } = parsePie(c.data);
2276
- const r = Math.min(c.w * 0.38, (c.h - (c.title ? 24 : 8)) * 0.44);
2275
+ const r = Math.min(c.w * 0.38, (c.h - (c.label ? 24 : 8)) * 0.44);
2277
2276
  const ir = c.chartType === 'donut' ? r * 0.48 : 0;
2278
2277
  const legendX = c.x + 8;
2279
- const legendY = c.y + (c.title ? 28 : 12);
2278
+ const legendY = c.y + (c.label ? 28 : 12);
2280
2279
  let angle = -Math.PI / 2;
2281
2280
  for (const seg of segments) {
2282
2281
  const sweep = (seg.value / total) * Math.PI * 2;
@@ -2314,7 +2313,7 @@ var AIDiagram = (function (exports) {
2314
2313
  strokeWidth: 1.2,
2315
2314
  }));
2316
2315
  });
2317
- legend(cg, pts.map(p => p.label), CHART_COLORS, c.x + 8, c.y + (c.title ? 28 : 12), lc, cFont);
2316
+ legend(cg, pts.map(p => p.label), CHART_COLORS, c.x + 8, c.y + (c.label ? 28 : 12), lc, cFont);
2318
2317
  return cg;
2319
2318
  }
2320
2319
  // ── Bar / Line / Area ─────────────────────────────────────
@@ -5565,7 +5564,6 @@ var AIDiagram = (function (exports) {
5565
5564
  NoteL.appendChild(ng);
5566
5565
  }
5567
5566
  svg.appendChild(NoteL);
5568
- markdownMap(sg);
5569
5567
  const MDL = mkGroup('markdown-layer');
5570
5568
  for (const m of sg.markdowns) {
5571
5569
  const mg = mkGroup(`markdown-${m.id}`, 'mdg');
@@ -5761,23 +5759,23 @@ var AIDiagram = (function (exports) {
5761
5759
  ...(s.strokeDash ? { strokeLineDash: s.strokeDash } : {}),
5762
5760
  });
5763
5761
  // Title
5764
- if (c.title) {
5762
+ if (c.label) {
5765
5763
  ctx.save();
5766
5764
  ctx.font = `${cFontWeight} ${cFontSize}px ${cFont}`;
5767
5765
  ctx.fillStyle = lc;
5768
5766
  ctx.textAlign = 'center';
5769
5767
  ctx.textBaseline = 'middle';
5770
- ctx.fillText(c.title, c.x + c.w / 2, c.y + 14);
5768
+ ctx.fillText(c.label, c.x + c.w / 2, c.y + 14);
5771
5769
  ctx.restore();
5772
5770
  }
5773
5771
  const { px, py, pw, ph, cx, cy } = chartLayout(c);
5774
5772
  // ── Pie / Donut ──────────────────────────────────────────
5775
5773
  if (c.chartType === 'pie' || c.chartType === 'donut') {
5776
5774
  const { segments, total } = parsePie(c.data);
5777
- const r = Math.min(c.w * 0.38, (c.h - (c.title ? 24 : 8)) * 0.44);
5775
+ const r = Math.min(c.w * 0.38, (c.h - (c.label ? 24 : 8)) * 0.44);
5778
5776
  const ir = c.chartType === 'donut' ? r * 0.48 : 0;
5779
5777
  const legendX = c.x + 8;
5780
- const legendY = c.y + (c.title ? 28 : 12);
5778
+ const legendY = c.y + (c.label ? 28 : 12);
5781
5779
  let angle = -Math.PI / 2;
5782
5780
  segments.forEach((seg, i) => {
5783
5781
  const sweep = (seg.value / total) * Math.PI * 2;
@@ -5805,7 +5803,7 @@ var AIDiagram = (function (exports) {
5805
5803
  strokeWidth: 1.2,
5806
5804
  });
5807
5805
  });
5808
- drawLegend(ctx, pts.map(p => p.label), CHART_COLORS, c.x + 8, c.y + (c.title ? 28 : 12), lc, cFont);
5806
+ drawLegend(ctx, pts.map(p => p.label), CHART_COLORS, c.x + 8, c.y + (c.label ? 28 : 12), lc, cFont);
5809
5807
  ctx.globalAlpha = 1;
5810
5808
  return;
5811
5809
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sketchmark",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "A plain-text DSL for hand-drawn diagrams. Write boxes, edges, and groups as code — renders sketchy SVG/Canvas via rough.js with a built-in step-by-step animation system.",
5
5
  "keywords": [
6
6
  "diagram",