@hattoriai/poney-react 0.1.0 → 0.2.0

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/dist/index.d.ts CHANGED
@@ -655,7 +655,7 @@ declare function Glyph({ name, x, y, size, color, strokeWidth }: {
655
655
  strokeWidth?: number;
656
656
  }): react.JSX.Element;
657
657
 
658
- /** Named pigments map to theme variables (--poney-<name>; the tone "poney" is --poney-accent); hex colors pass through. */
658
+ /** Named pigments map to theme variables (--poney-<name>); hex colors pass through. */
659
659
  declare const toneColor: (tone: Tone | string) => string;
660
660
  /** A pale wash of a tone over paper, for fills. */
661
661
  declare const toneWash: (tone: Tone | string, amount?: number) => string;
package/dist/index.js CHANGED
@@ -134,7 +134,7 @@ function expandFocus(refs, idx, walkthrough) {
134
134
  }
135
135
  return [...out];
136
136
  }
137
- var BOX = /^(entity|state|dataType|activityNode|capability):/;
137
+ var BOX = /^(entity|state|dataType|activityNode|useCase):/;
138
138
  function sceneFrame(scene, view, focus, idx, walkthrough) {
139
139
  const rects = expandFocus(focus, idx, walkthrough).map((k) => scene.anchors[k]).filter((r) => !!r);
140
140
  if (!rects.length || view.type === "sequence") return { x: 0, y: 0, w: scene.width, h: scene.height };
@@ -307,7 +307,7 @@ function Glyph({ name, x, y, size = 16, color = "currentColor", strokeWidth = 1.
307
307
  }
308
308
 
309
309
  // src/tone.ts
310
- var toneColor = (tone) => tone.startsWith("#") ? tone : `var(--poney-${tone === "poney" ? "accent" : tone})`;
310
+ var toneColor = (tone) => tone.startsWith("#") ? tone : `var(--poney-${tone})`;
311
311
  var toneWash = (tone, amount = 10) => `color-mix(in srgb, ${toneColor(tone)} ${amount}%, var(--poney-paper-raised))`;
312
312
  function MapStory({ scene, extra = [] }) {
313
313
  const idx = useRenderIndex();
@@ -804,7 +804,7 @@ var DEFAULT_COLOR = {
804
804
  blocked: "var(--poney-failure)"
805
805
  };
806
806
  var colorOf = (as, tone) => tone ? toneColor(tone) : DEFAULT_COLOR[as];
807
- var isBox = (k) => /^(entity|state|dataType|activityNode|capability):/.test(k);
807
+ var isBox = (k) => /^(entity|state|dataType|activityNode|useCase):/.test(k);
808
808
  function EmphasisUnder({ scene, view }) {
809
809
  const s = useStory();
810
810
  if (!s.effects?.size) return null;
@@ -1676,10 +1676,10 @@ function Renderer4({ scene }) {
1676
1676
  const outcome = n.outcome === "failure" ? "var(--poney-failure)" : n.outcome === "success" ? "var(--poney-success)" : "var(--poney-ink)";
1677
1677
  let body;
1678
1678
  switch (n.kind) {
1679
- case "start":
1679
+ case "initial":
1680
1680
  body = /* @__PURE__ */ jsx("circle", { cx: w / 2, cy: h / 2, r: w / 2, fill: "var(--poney-ink)" });
1681
1681
  break;
1682
- case "end":
1682
+ case "final":
1683
1683
  body = /* @__PURE__ */ jsxs(Fragment, { children: [
1684
1684
  /* @__PURE__ */ jsx("circle", { cx: w / 2, cy: h / 2, r: w / 2, fill: "var(--poney-paper-raised)", stroke: outcome, strokeWidth: 1.6 }),
1685
1685
  /* @__PURE__ */ jsx("circle", { cx: w / 2, cy: h / 2, r: w / 2 - 5.5, fill: outcome }),
@@ -1707,7 +1707,7 @@ function Renderer4({ scene }) {
1707
1707
  return /* @__PURE__ */ jsxs("g", { transform: `translate(${x} ${y})`, ...bind(ref, label), className: `poney-el ${dim ? "poney-dim" : ""}`, children: [
1708
1708
  pad > 0 && /* @__PURE__ */ jsx("rect", { x: 0, y: -pad, width: w, height: h + pad * 2, fill: "transparent" }),
1709
1709
  body,
1710
- /* @__PURE__ */ jsx(Rings, { w, h, rx: n.kind === "start" || n.kind === "end" ? w / 2 : 10, selected })
1710
+ /* @__PURE__ */ jsx(Rings, { w, h, rx: n.kind === "initial" || n.kind === "final" ? w / 2 : 10, selected })
1711
1711
  ] }, n.id);
1712
1712
  })
1713
1713
  ] });
@@ -1750,7 +1750,7 @@ function Cardinal({ p, d, card, color }) {
1750
1750
  }) });
1751
1751
  };
1752
1752
  return /* @__PURE__ */ jsxs("g", { children: [
1753
- card === "one" && /* @__PURE__ */ jsxs(Fragment, { children: [
1753
+ card === "exactly-one" && /* @__PURE__ */ jsxs(Fragment, { children: [
1754
1754
  bar(6),
1755
1755
  bar(11)
1756
1756
  ] }),
@@ -1758,7 +1758,7 @@ function Cardinal({ p, d, card, color }) {
1758
1758
  bar(6),
1759
1759
  circle(15)
1760
1760
  ] }),
1761
- card === "many" && /* @__PURE__ */ jsxs(Fragment, { children: [
1761
+ card === "zero-or-many" && /* @__PURE__ */ jsxs(Fragment, { children: [
1762
1762
  crow(),
1763
1763
  circle(18)
1764
1764
  ] }),
@@ -1920,10 +1920,10 @@ function Legend5() {
1920
1920
  label
1921
1921
  ] });
1922
1922
  return /* @__PURE__ */ jsxs("div", { className: "poney-legend", children: [
1923
- row("one", "Exactly one"),
1923
+ row("exactly-one", "Exactly one"),
1924
1924
  row("zero-or-one", "Zero or one"),
1925
1925
  row("one-or-many", "One or more"),
1926
- row("many", "Any number"),
1926
+ row("zero-or-many", "Zero or many"),
1927
1927
  /* @__PURE__ */ jsx(LegendRow, { line: "dashed", label: "Across databases, kept by code", head: false }),
1928
1928
  /* @__PURE__ */ jsxs("div", { className: "poney-legend-row", children: [
1929
1929
  /* @__PURE__ */ jsx(KeyRound, { size: 13, style: { margin: "0 4px", color: "var(--poney-ochre)" } }),
@@ -2043,15 +2043,15 @@ function Renderer7({ scene }) {
2043
2043
  const caps = /* @__PURE__ */ new Set();
2044
2044
  if (subject.kind === "entity" && scene.actors.some((a) => a.entityId === subject.id)) {
2045
2045
  actors.add(subject.id);
2046
- scene.associations.forEach((a) => a.actor === subject.id && caps.add(a.capability));
2047
- } else if (subject.kind === "capability" && scene.capabilities.some((c) => c.id === subject.id)) {
2046
+ scene.associations.forEach((a) => a.actor === subject.id && caps.add(a.useCase));
2047
+ } else if (subject.kind === "useCase" && scene.useCases.some((c) => c.id === subject.id)) {
2048
2048
  caps.add(subject.id);
2049
- scene.associations.forEach((a) => a.capability === subject.id && actors.add(a.actor));
2049
+ scene.associations.forEach((a) => a.useCase === subject.id && actors.add(a.actor));
2050
2050
  scene.includes.forEach((i) => i.from === subject.id && caps.add(i.to));
2051
2051
  } else return null;
2052
2052
  return { actors, caps };
2053
2053
  }, [subject, scene]);
2054
- const hotAssoc = (a) => !!focus && focus.caps.has(a.capability) && focus.actors.has(a.actor);
2054
+ const hotAssoc = (a) => !!focus && focus.caps.has(a.useCase) && focus.actors.has(a.actor);
2055
2055
  return /* @__PURE__ */ jsxs("g", { children: [
2056
2056
  /* @__PURE__ */ jsx("rect", { x: scene.boundary.x, y: scene.boundary.y, width: scene.boundary.w, height: scene.boundary.h, rx: 22, fill: "var(--poney-paper)", fillOpacity: 0.6, stroke: "var(--poney-rule-strong)" }),
2057
2057
  /* @__PURE__ */ jsx("text", { x: scene.boundary.x + 20, y: scene.boundary.y + 30, fontSize: 13, fontWeight: 650, fill: "var(--poney-ink-2)", children: scene.boundary.title }),
@@ -2085,11 +2085,11 @@ function Renderer7({ scene }) {
2085
2085
  /* @__PURE__ */ jsx("text", { x: i.a.x + 44, y: (i.a.y + i.b.y) / 2 + 4, fontSize: 11, fontStyle: "italic", fill: color, children: "includes" })
2086
2086
  ] }, i.id);
2087
2087
  }),
2088
- scene.capabilities.map((c) => {
2089
- const cap = idx.capabilities.get(c.id);
2088
+ scene.useCases.map((c) => {
2089
+ const cap = idx.useCases.get(c.id);
2090
2090
  const dim = focus && !focus.caps.has(c.id);
2091
- const selected = selection?.kind === "capability" && selection.id === c.id;
2092
- return /* @__PURE__ */ jsxs("g", { transform: `translate(${c.x} ${c.y})`, ...bind({ kind: "capability", id: c.id }, `${cap.name}. ${cap.summary}`), className: `poney-el ${dim ? "poney-dim" : ""}`, children: [
2091
+ const selected = selection?.kind === "useCase" && selection.id === c.id;
2092
+ return /* @__PURE__ */ jsxs("g", { transform: `translate(${c.x} ${c.y})`, ...bind({ kind: "useCase", id: c.id }, `${cap.name}. ${cap.summary}`), className: `poney-el ${dim ? "poney-dim" : ""}`, children: [
2093
2093
  /* @__PURE__ */ jsx("rect", { className: "poney-body", width: c.w, height: c.h, rx: c.h / 2, fill: "var(--poney-paper-raised)", stroke: focus?.caps.has(c.id) ? "var(--poney-tyrian)" : "var(--poney-rule-strong)", strokeWidth: 1.2 }),
2094
2094
  /* @__PURE__ */ jsx("text", { x: c.w / 2, y: c.h / 2 + 5, textAnchor: "middle", fontSize: 13.5, fontWeight: 600, fill: "var(--poney-ink)", children: clip(cap.name, c.w - 32, 13.5, 600) }),
2095
2095
  /* @__PURE__ */ jsx(Rings, { w: c.w, h: c.h, rx: c.h / 2, selected })
@@ -2192,18 +2192,27 @@ function Renderer8({ scene, view }) {
2192
2192
  const up = focus?.userEdges.has(e.id);
2193
2193
  const groupHot = focus?.group && (focus.deps.has(e.source) || focus.deps.has(e.target));
2194
2194
  const color = down ? DOWN : up ? UP : groupHot ? "var(--poney-ink-2)" : "var(--poney-ink-4)";
2195
- const [p0, c1, c2, p3] = e.d;
2195
+ const p3 = e.d[e.d.length - 1];
2196
+ const c2 = e.d[e.d.length - 2];
2196
2197
  const angle = Math.atan2(p3.y - c2.y, p3.x - c2.x);
2197
2198
  const back = ls.head === "triangle" ? 10 : 6;
2198
2199
  const end = { x: p3.x - Math.cos(angle) * back, y: p3.y - Math.sin(angle) * back };
2200
+ const path = (last) => {
2201
+ let d = `M ${e.d[0].x} ${e.d[0].y}`;
2202
+ for (let i = 1; i + 2 < e.d.length; i += 3) {
2203
+ const to = i + 2 === e.d.length - 1 ? last : e.d[i + 2];
2204
+ d += ` C ${e.d[i].x} ${e.d[i].y} ${e.d[i + 1].x} ${e.d[i + 1].y} ${to.x} ${to.y}`;
2205
+ }
2206
+ return d;
2207
+ };
2199
2208
  const dim = focus && !down && !up && !groupHot;
2200
2209
  const rel = idx.relationships.get(e.id);
2201
2210
  return /* @__PURE__ */ jsxs("g", { ...bind({ kind: "relationship", id: e.id }, `${idx.entities.get(e.source)?.name} ${rel?.kind === "implements" ? "implements" : "depends on"} ${idx.entities.get(e.target)?.name}`), className: `poney-el ${dim ? "poney-dim" : ""}`, children: [
2202
- /* @__PURE__ */ jsx("path", { d: `M ${p0.x} ${p0.y} C ${c1.x} ${c1.y} ${c2.x} ${c2.y} ${p3.x} ${p3.y}`, fill: "none", stroke: "transparent", strokeWidth: 12 }),
2211
+ /* @__PURE__ */ jsx("path", { d: path(p3), fill: "none", stroke: "transparent", strokeWidth: 12 }),
2203
2212
  /* @__PURE__ */ jsx(
2204
2213
  "path",
2205
2214
  {
2206
- d: `M ${p0.x} ${p0.y} C ${c1.x} ${c1.y} ${c2.x} ${c2.y} ${end.x} ${end.y}`,
2215
+ d: path(end),
2207
2216
  fill: "none",
2208
2217
  stroke: color,
2209
2218
  strokeWidth: down || up ? 1.9 : 1.2,