sketchmark 0.1.9 → 0.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,UAAU,EAmBX,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA8B/C,qBAAa,UAAW,SAAQ,KAAK;IAG1B,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,MAAM;gBAFlB,GAAG,EAAE,MAAM,EACJ,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM;CAKrB;AA8BD,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAs7B7C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,UAAU,EAmBX,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA8B/C,qBAAa,UAAW,SAAQ,KAAK;IAG1B,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,MAAM;gBAFlB,GAAG,EAAE,MAAM,EACJ,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM;CAKrB;AA8BD,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAu7B7C"}
@@ -837,6 +837,7 @@ var AIDiagram = (function (exports) {
837
837
  v === "config" || // ← ADD
838
838
  v === "theme" || // ← ADD
839
839
  v === "style" ||
840
+ v === "markdown" ||
840
841
  CHART_TYPES.includes(v)) {
841
842
  break;
842
843
  }
@@ -6399,6 +6400,7 @@ var AIDiagram = (function (exports) {
6399
6400
  const getTableEl = (svg, id) => getEl(svg, `table-${id}`);
6400
6401
  const getNoteEl = (svg, id) => getEl(svg, `note-${id}`);
6401
6402
  const getChartEl = (svg, id) => getEl(svg, `chart-${id}`);
6403
+ const getMarkdownEl = (svg, id) => getEl(svg, `markdown-${id}`);
6402
6404
  function resolveEl(svg, target) {
6403
6405
  // check edge first — target contains connector like "a-->b"
6404
6406
  const edge = parseEdgeTarget(target);
@@ -6410,6 +6412,7 @@ var AIDiagram = (function (exports) {
6410
6412
  getTableEl(svg, target) ??
6411
6413
  getNoteEl(svg, target) ??
6412
6414
  getChartEl(svg, target) ??
6415
+ getMarkdownEl(svg, target) ??
6413
6416
  null);
6414
6417
  }
6415
6418
  function pathLength(p) {
@@ -6420,6 +6423,15 @@ var AIDiagram = (function (exports) {
6420
6423
  return 200;
6421
6424
  }
6422
6425
  }
6426
+ function clearDashOverridesAfter(el, delayMs) {
6427
+ setTimeout(() => {
6428
+ el.querySelectorAll('path').forEach(p => {
6429
+ p.style.strokeDasharray = '';
6430
+ p.style.strokeDashoffset = '';
6431
+ p.style.transition = '';
6432
+ });
6433
+ }, delayMs);
6434
+ }
6423
6435
  // ── Arrow connector parser ────────────────────────────────
6424
6436
  const ARROW_CONNECTORS = ["<-->", "<->", "-->", "<--", "->", "<-", "---", "--"];
6425
6437
  function parseEdgeTarget(target) {
@@ -6527,32 +6539,39 @@ var AIDiagram = (function (exports) {
6527
6539
  });
6528
6540
  }
6529
6541
  function animateEdgeDraw(el, conn) {
6530
- const paths = Array.from(el.querySelectorAll("path"));
6542
+ const paths = Array.from(el.querySelectorAll('path'));
6531
6543
  if (!paths.length)
6532
6544
  return;
6533
6545
  const linePath = paths[0];
6534
6546
  const headPaths = paths.slice(1);
6535
6547
  const STROKE_DUR = 360;
6536
6548
  const len = pathLength(linePath);
6537
- const reversed = conn.startsWith("<") && !conn.includes(">");
6549
+ const reversed = conn.startsWith('<') && !conn.includes('>');
6538
6550
  linePath.style.strokeDasharray = `${len}`;
6539
6551
  linePath.style.strokeDashoffset = reversed ? `${-len}` : `${len}`;
6540
- linePath.style.transition = "none";
6541
- headPaths.forEach((p) => {
6542
- p.style.opacity = "0";
6543
- p.style.transition = "none";
6552
+ linePath.style.transition = 'none';
6553
+ headPaths.forEach(p => {
6554
+ p.style.opacity = '0';
6555
+ p.style.transition = 'none';
6544
6556
  });
6545
- el.classList.remove("draw-hidden");
6546
- el.classList.add("draw-reveal");
6547
- el.style.opacity = "1";
6557
+ el.classList.remove('draw-hidden');
6558
+ el.classList.add('draw-reveal');
6559
+ el.style.opacity = '1';
6548
6560
  requestAnimationFrame(() => requestAnimationFrame(() => {
6549
6561
  linePath.style.transition = `stroke-dashoffset ${STROKE_DUR}ms cubic-bezier(.4,0,.2,1)`;
6550
- linePath.style.strokeDashoffset = "0";
6562
+ linePath.style.strokeDashoffset = '0';
6551
6563
  setTimeout(() => {
6552
- headPaths.forEach((p) => {
6553
- p.style.transition = "opacity 120ms ease";
6554
- p.style.opacity = "1";
6564
+ headPaths.forEach(p => {
6565
+ p.style.transition = 'opacity 120ms ease';
6566
+ p.style.opacity = '1';
6555
6567
  });
6568
+ // ── ADD: clear inline dash overrides so SVG attribute
6569
+ // (stroke-dasharray="6,5" for dashed arrows) takes over again
6570
+ setTimeout(() => {
6571
+ linePath.style.strokeDasharray = '';
6572
+ linePath.style.strokeDashoffset = '';
6573
+ linePath.style.transition = '';
6574
+ }, 160);
6556
6575
  }, STROKE_DUR - 40);
6557
6576
  }));
6558
6577
  }
@@ -6576,6 +6595,7 @@ var AIDiagram = (function (exports) {
6576
6595
  this.drawTargetTables = new Set();
6577
6596
  this.drawTargetNotes = new Set();
6578
6597
  this.drawTargetCharts = new Set();
6598
+ this.drawTargetMarkdowns = new Set();
6579
6599
  for (const s of steps) {
6580
6600
  if (s.action !== "draw" || parseEdgeTarget(s.target))
6581
6601
  continue;
@@ -6596,6 +6616,10 @@ var AIDiagram = (function (exports) {
6596
6616
  this.drawTargetCharts.add(`chart-${s.target}`);
6597
6617
  this.drawTargetNodes.delete(`node-${s.target}`);
6598
6618
  }
6619
+ if (svg.querySelector(`#markdown-${s.target}`)) {
6620
+ this.drawTargetMarkdowns.add(`markdown-${s.target}`);
6621
+ this.drawTargetNodes.delete(`node-${s.target}`);
6622
+ }
6599
6623
  }
6600
6624
  this._clearAll();
6601
6625
  }
@@ -6767,7 +6791,24 @@ var AIDiagram = (function (exports) {
6767
6791
  });
6768
6792
  }
6769
6793
  });
6770
- this.svg.querySelectorAll(".tg, .ntg, .cg").forEach((el) => {
6794
+ // Markdown
6795
+ this.svg.querySelectorAll(".mdg").forEach((el) => {
6796
+ clearDrawStyles(el);
6797
+ el.style.transition = "none";
6798
+ el.style.opacity = "";
6799
+ if (this.drawTargetMarkdowns.has(el.id)) {
6800
+ el.classList.add("gg-hidden");
6801
+ }
6802
+ else {
6803
+ el.classList.remove("gg-hidden");
6804
+ requestAnimationFrame(() => {
6805
+ el.style.transition = "";
6806
+ });
6807
+ }
6808
+ });
6809
+ this.svg
6810
+ .querySelectorAll(".tg, .ntg, .cg, .mdg")
6811
+ .forEach((el) => {
6771
6812
  el.style.transform = "";
6772
6813
  el.style.transition = "";
6773
6814
  el.style.opacity = "";
@@ -6945,6 +6986,9 @@ var AIDiagram = (function (exports) {
6945
6986
  if (!firstPath?.style.strokeDasharray)
6946
6987
  prepareForDraw(groupEl);
6947
6988
  animateShapeDraw(groupEl, 550, 40);
6989
+ const pathCount = groupEl.querySelectorAll('path').length;
6990
+ const totalMs = pathCount * 40 + 550 + 120; // stagger + duration + buffer
6991
+ clearDashOverridesAfter(groupEl, totalMs);
6948
6992
  }
6949
6993
  return;
6950
6994
  }
@@ -6965,6 +7009,8 @@ var AIDiagram = (function (exports) {
6965
7009
  tableEl.classList.remove("gg-hidden");
6966
7010
  prepareForDraw(tableEl);
6967
7011
  animateShapeDraw(tableEl, 500, 40);
7012
+ const tablePathCount = tableEl.querySelectorAll('path').length;
7013
+ clearDashOverridesAfter(tableEl, tablePathCount * 40 + 500 + 120);
6968
7014
  }
6969
7015
  return;
6970
7016
  }
@@ -6985,6 +7031,8 @@ var AIDiagram = (function (exports) {
6985
7031
  noteEl.classList.remove("gg-hidden");
6986
7032
  prepareForDraw(noteEl);
6987
7033
  animateShapeDraw(noteEl, 420, 55);
7034
+ const notePathCount = noteEl.querySelectorAll('path').length;
7035
+ clearDashOverridesAfter(noteEl, notePathCount * 55 + 420 + 120);
6988
7036
  }
6989
7037
  return;
6990
7038
  }
@@ -7012,6 +7060,28 @@ var AIDiagram = (function (exports) {
7012
7060
  }
7013
7061
  return;
7014
7062
  }
7063
+ // ── Markdown ──────────────────────────────────────────
7064
+ const markdownEl = getMarkdownEl(this.svg, target);
7065
+ if (markdownEl) {
7066
+ if (silent) {
7067
+ markdownEl.style.transition = "none";
7068
+ markdownEl.style.opacity = "";
7069
+ markdownEl.classList.remove("gg-hidden");
7070
+ markdownEl.style.opacity = "1";
7071
+ requestAnimationFrame(() => requestAnimationFrame(() => {
7072
+ markdownEl.style.transition = "";
7073
+ }));
7074
+ }
7075
+ else {
7076
+ markdownEl.style.opacity = "0";
7077
+ markdownEl.classList.remove("gg-hidden");
7078
+ requestAnimationFrame(() => requestAnimationFrame(() => {
7079
+ markdownEl.style.transition = "opacity 500ms ease";
7080
+ markdownEl.style.opacity = "1";
7081
+ }));
7082
+ }
7083
+ return;
7084
+ }
7015
7085
  // ── Node draw ──────────────────────────────────────
7016
7086
  const nodeEl = getNodeEl(this.svg, target);
7017
7087
  if (!nodeEl)
@@ -7025,14 +7095,16 @@ var AIDiagram = (function (exports) {
7025
7095
  if (!firstPath?.style.strokeDasharray)
7026
7096
  prepareForDraw(nodeEl);
7027
7097
  animateShapeDraw(nodeEl, 420, 55);
7098
+ const nodePathCount = nodeEl.querySelectorAll('path').length;
7099
+ clearDashOverridesAfter(nodeEl, nodePathCount * 55 + 420 + 120);
7028
7100
  }
7029
7101
  }
7030
7102
  // ── erase ─────────────────────────────────────────────────
7031
7103
  _doErase(target) {
7032
7104
  const el = resolveEl(this.svg, target); // handles edges too now
7033
7105
  if (el) {
7034
- el.style.transition = 'opacity 0.4s';
7035
- el.style.opacity = '0';
7106
+ el.style.transition = "opacity 0.4s";
7107
+ el.style.opacity = "0";
7036
7108
  }
7037
7109
  }
7038
7110
  // ── show / hide ───────────────────────────────────────────
@@ -7060,10 +7132,10 @@ var AIDiagram = (function (exports) {
7060
7132
  return;
7061
7133
  // edge — color stroke
7062
7134
  if (parseEdgeTarget(target)) {
7063
- el.querySelectorAll('path, line, polyline').forEach(p => {
7135
+ el.querySelectorAll("path, line, polyline").forEach((p) => {
7064
7136
  p.style.stroke = color;
7065
7137
  });
7066
- el.querySelectorAll('polygon').forEach(p => {
7138
+ el.querySelectorAll("polygon").forEach((p) => {
7067
7139
  p.style.fill = color;
7068
7140
  p.style.stroke = color;
7069
7141
  });
@@ -7071,22 +7143,24 @@ var AIDiagram = (function (exports) {
7071
7143
  }
7072
7144
  // everything else — color fill
7073
7145
  let hit = false;
7074
- el.querySelectorAll('path, rect, ellipse, polygon').forEach(c => {
7075
- const attrFill = c.getAttribute('fill');
7076
- if (attrFill === 'none')
7146
+ el.querySelectorAll("path, rect, ellipse, polygon").forEach((c) => {
7147
+ const attrFill = c.getAttribute("fill");
7148
+ if (attrFill === "none")
7077
7149
  return;
7078
- if (attrFill === null && c.tagName === 'path')
7150
+ if (attrFill === null && c.tagName === "path")
7079
7151
  return;
7080
7152
  c.style.fill = color;
7081
7153
  hit = true;
7082
7154
  });
7083
7155
  if (!hit) {
7084
- el.querySelectorAll('text').forEach(t => { t.style.fill = color; });
7156
+ el.querySelectorAll("text").forEach((t) => {
7157
+ t.style.fill = color;
7158
+ });
7085
7159
  }
7086
7160
  }
7087
7161
  }
7088
7162
  const ANIMATION_CSS = `
7089
- .ng, .gg, .tg, .ntg, .cg, .eg {
7163
+ .ng, .gg, .tg, .ntg, .cg, .eg, .mdg {
7090
7164
  transform-box: fill-box;
7091
7165
  transform-origin: center;
7092
7166
  transition: filter 0.3s, opacity 0.35s;
@@ -7097,9 +7171,10 @@ var AIDiagram = (function (exports) {
7097
7171
  .tg.hl path, .tg.hl rect,
7098
7172
  .ntg.hl path, .ntg.hl polygon,
7099
7173
  .cg.hl path, .cg.hl rect,
7174
+ .mdg.hl text,
7100
7175
  .eg.hl path, .eg.hl line, .eg.hl polygon { stroke-width: 2.8 !important; }
7101
7176
 
7102
- .ng.hl, .tg.hl, .ntg.hl, .cg.hl, .eg.hl {
7177
+ .ng.hl, .tg.hl, .ntg.hl, .cg.hl, .mdg.hl, .eg.hl {
7103
7178
  animation: ng-pulse 1.4s ease-in-out infinite;
7104
7179
  }
7105
7180
  @keyframes ng-pulse {
@@ -7108,7 +7183,8 @@ var AIDiagram = (function (exports) {
7108
7183
  }
7109
7184
 
7110
7185
  /* fade */
7111
- .ng.faded, .gg.faded, .tg.faded, .ntg.faded, .cg.faded, .eg.faded { opacity: 0.22; }
7186
+ .ng.faded, .gg.faded, .tg.faded, .ntg.faded,
7187
+ .cg.faded, .eg.faded, .mdg.faded { opacity: 0.22; }
7112
7188
 
7113
7189
  .ng.hidden { opacity: 0; pointer-events: none; }
7114
7190
  .eg.draw-hidden { opacity: 0; }
@@ -7117,6 +7193,7 @@ var AIDiagram = (function (exports) {
7117
7193
  .tg.gg-hidden { opacity: 0; }
7118
7194
  .ntg.gg-hidden { opacity: 0; }
7119
7195
  .cg.gg-hidden { opacity: 0; }
7196
+ .mdg.gg-hidden { opacity: 0; }
7120
7197
  `;
7121
7198
 
7122
7199
  // ============================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sketchmark",
3
- "version": "0.1.9",
3
+ "version": "0.2.1",
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",