@hattoriai/poney-diagrams 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +23 -2
- package/dist/MapStory.d.ts +9 -0
- package/dist/SceneStory.d.ts +10 -0
- package/dist/SequenceStory.d.ts +5 -0
- package/dist/StateStory.d.ts +7 -0
- package/dist/chunk-HQ6ICBI7.js +96 -0
- package/dist/chunk-HQ6ICBI7.js.map +1 -0
- package/dist/context.d.ts +86 -0
- package/dist/diagrams/activity/index.d.ts +6 -0
- package/dist/diagrams/architecture/index.d.ts +6 -0
- package/dist/diagrams/dataflow/index.d.ts +6 -0
- package/dist/diagrams/dependency/index.d.ts +6 -0
- package/dist/diagrams/erd/index.d.ts +6 -0
- package/dist/diagrams/index.d.ts +12 -0
- package/dist/diagrams/map/index.d.ts +6 -0
- package/dist/diagrams/registry.d.ts +9 -0
- package/dist/diagrams/sequence/index.d.ts +6 -0
- package/dist/diagrams/shared/Edge.d.ts +41 -0
- package/dist/diagrams/shared/EntityNode.d.ts +32 -0
- package/dist/diagrams/shared/Legend.d.ts +14 -0
- package/dist/diagrams/shared/icons.d.ts +1 -0
- package/dist/diagrams/shared/tone.d.ts +1 -0
- package/dist/diagrams/state/index.d.ts +6 -0
- package/dist/diagrams/types.d.ts +30 -0
- package/dist/diagrams/usecase/index.d.ts +6 -0
- package/dist/emphasis.d.ts +43 -0
- package/dist/host.d.ts +26 -0
- package/dist/icons.d.ts +53 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +2647 -0
- package/dist/index.js.map +1 -0
- package/dist/poney.css +211 -0
- package/dist/poney.min.css +1 -0
- package/dist/render.d.ts +79 -0
- package/dist/runtime/core.d.ts +67 -0
- package/dist/runtime/dom.d.ts +8 -0
- package/dist/runtime/events.d.ts +20 -0
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/jsx-dev-runtime.d.ts +1 -0
- package/dist/runtime/jsx-dev-runtime.js +3 -0
- package/dist/runtime/jsx-dev-runtime.js.map +1 -0
- package/dist/runtime/jsx-runtime.d.ts +39 -0
- package/dist/runtime/jsx-runtime.js +3 -0
- package/dist/runtime/jsx-runtime.js.map +1 -0
- package/dist/runtime/markup.d.ts +15 -0
- package/dist/scene.d.ts +436 -0
- package/dist/theme.d.ts +79 -0
- package/dist/tone.d.ts +5 -0
- package/package.json +58 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rui Freitas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @hattoriai/poney-diagrams
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Draws Poney documents as SVG, with no UI framework: every diagram type (architecture, map, sequence, data flow, activity, ERD, state, use case, dependency) and walkthrough scenes, from a scene laid out by `@hattoriai/poney-layout`. Your page is the host: it gives the model index and, if it wants, interaction, selection and view state. Without them a diagram is a still picture.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import '@hattoriai/poney-diagrams/styles.css'
|
|
7
|
+
import { diagramFor, drawInto } from '@hattoriai/poney-diagrams'
|
|
8
|
+
import { indexOf } from '@hattoriai/poney-core'
|
|
9
|
+
import { layoutView } from '@hattoriai/poney-layout'
|
|
10
|
+
|
|
11
|
+
const view = doc.views[0]
|
|
12
|
+
const scene = await layoutView(doc, view)
|
|
13
|
+
const svg = document.querySelector('svg')!
|
|
14
|
+
svg.setAttribute('viewBox', `0 0 ${scene.width} ${scene.height}`)
|
|
15
|
+
drawInto(svg, diagramFor(view)!.Renderer, { scene, view }, { render: { idx: indexOf(doc) } })
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`drawInto` draws again after a local change (an open group, a hovered line) and changes only what changed, so focus, hover and transitions survive. `resolve` and `toMarkup` give the same drawing as SVG text, for a server or a file. For React, use `@hattoriai/poney-react`.
|
|
19
|
+
|
|
20
|
+
The renderers are plain functions in JSX for this package's small runtime (`/** @jsxImportSource @hattoriai/poney-diagrams */`). An extension writes its renderers the same way and registers them with `registerDiagram`.
|
|
21
|
+
|
|
22
|
+
The stylesheet is plain CSS (1.3 KB gzipped): `--poney-*` tokens and `.poney-*` classes, in the cascade layer `poney`, so your styles win. Set `data-poney-theme="dark"` on any element for dark. Without a bundler, use `@hattoriai/poney-diagrams/styles.min.css`.
|
|
23
|
+
|
|
24
|
+
Part of [Poney](https://github.com/hattoriai/poney): the format, the renderers, and tools to explain software. MIT licensed.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource @hattoriai/poney-diagrams */
|
|
3
|
+
import type { Entity } from '@hattoriai/poney-core';
|
|
4
|
+
import { type MapScene } from '@hattoriai/poney-layout';
|
|
5
|
+
/** Draws a map scene in the crisp story style. */
|
|
6
|
+
export declare function MapStory({ scene, extra }: {
|
|
7
|
+
scene: MapScene;
|
|
8
|
+
extra?: Entity[];
|
|
9
|
+
}): import("./runtime").Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource @hattoriai/poney-diagrams */
|
|
3
|
+
import type { Entity, View } from '@hattoriai/poney-core';
|
|
4
|
+
import type { SceneBase } from '@hattoriai/poney-layout';
|
|
5
|
+
/** Draws a map, sequence or state scene in the story style, with its effects, badges and trace. */
|
|
6
|
+
export declare function SceneStory({ view, scene, extra }: {
|
|
7
|
+
view: View;
|
|
8
|
+
scene: SceneBase;
|
|
9
|
+
extra?: Entity[];
|
|
10
|
+
}): import("./runtime").Element | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource @hattoriai/poney-diagrams */
|
|
3
|
+
import { type StateScene } from '@hattoriai/poney-layout';
|
|
4
|
+
/** Draws a state machine scene in the crisp story style. */
|
|
5
|
+
export declare function StateStory({ scene }: {
|
|
6
|
+
scene: StateScene;
|
|
7
|
+
}): import("./runtime").Element;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// src/runtime/core.ts
|
|
2
|
+
var Fragment = /* @__PURE__ */ Symbol.for("poney.fragment");
|
|
3
|
+
function createElement(type, props, key = null) {
|
|
4
|
+
return { $$poney: true, type, props, key };
|
|
5
|
+
}
|
|
6
|
+
var isElement = (x) => typeof x === "object" && x !== null && x.$$poney === true;
|
|
7
|
+
var providers = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
function createContext(fallback) {
|
|
9
|
+
const id = /* @__PURE__ */ Symbol("poney.context");
|
|
10
|
+
const Provider = (p) => p.children;
|
|
11
|
+
providers.set(Provider, id);
|
|
12
|
+
return { id, fallback, Provider };
|
|
13
|
+
}
|
|
14
|
+
var current = null;
|
|
15
|
+
var resolving = false;
|
|
16
|
+
function useContext(ctx) {
|
|
17
|
+
if (!resolving) throw new Error("useContext is only for components while they draw");
|
|
18
|
+
for (let s = current; s; s = s.parent) if (s.id === ctx.id) return s.value;
|
|
19
|
+
return ctx.fallback;
|
|
20
|
+
}
|
|
21
|
+
var useMemo = (make, _deps) => make();
|
|
22
|
+
var useCallback = (fn, _deps) => fn;
|
|
23
|
+
var still = { get: () => void 0, has: () => false, update: () => {
|
|
24
|
+
} };
|
|
25
|
+
var LocalContext = createContext(still);
|
|
26
|
+
function localStore(redraw, values = /* @__PURE__ */ new Map()) {
|
|
27
|
+
return {
|
|
28
|
+
get: (key) => values.get(key),
|
|
29
|
+
has: (key) => values.has(key),
|
|
30
|
+
update(key, change) {
|
|
31
|
+
values.set(key, change(values.get(key)));
|
|
32
|
+
redraw();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function useLocal(key, initial) {
|
|
37
|
+
const store = useContext(LocalContext);
|
|
38
|
+
const value = store.has(key) ? store.get(key) : initial;
|
|
39
|
+
const set = (next) => store.update(key, (prev) => {
|
|
40
|
+
const base = prev === void 0 ? initial : prev;
|
|
41
|
+
return typeof next === "function" ? next(base) : next;
|
|
42
|
+
});
|
|
43
|
+
return [value, set];
|
|
44
|
+
}
|
|
45
|
+
function resolve(child) {
|
|
46
|
+
const was = { current, resolving };
|
|
47
|
+
resolving = true;
|
|
48
|
+
try {
|
|
49
|
+
const out = [];
|
|
50
|
+
walkList(child, null, "", out);
|
|
51
|
+
return out;
|
|
52
|
+
} finally {
|
|
53
|
+
current = was.current;
|
|
54
|
+
resolving = was.resolving;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function walkList(children, scope, prefix, out) {
|
|
58
|
+
if (!Array.isArray(children)) return walkOne(children, scope, prefix, "0", out);
|
|
59
|
+
const list = children;
|
|
60
|
+
for (let i = 0; i < list.length; i++) {
|
|
61
|
+
const item = list[i];
|
|
62
|
+
if (Array.isArray(item)) walkList(item, scope, `${prefix}${i}.`, out);
|
|
63
|
+
else walkOne(item, scope, prefix, String(i), out);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function walkOne(child, scope, prefix, slot, out) {
|
|
67
|
+
if (child === null || child === void 0 || typeof child === "boolean") return;
|
|
68
|
+
if (typeof child === "string") return void out.push(child);
|
|
69
|
+
if (typeof child === "number" || typeof child === "bigint") return void out.push(String(child));
|
|
70
|
+
const el = child;
|
|
71
|
+
const key = el.key === null ? `${prefix}${slot}` : `${prefix}=${el.key}`;
|
|
72
|
+
const { type } = el;
|
|
73
|
+
if (type === Fragment) return walkList(el.props.children, scope, `${key}/`, out);
|
|
74
|
+
if (typeof type === "function") {
|
|
75
|
+
const id = providers.get(type);
|
|
76
|
+
if (id) return walkList(el.props.children, { parent: scope, id, value: el.props.value }, `${key}/`, out);
|
|
77
|
+
current = scope;
|
|
78
|
+
const rendered = type(el.props);
|
|
79
|
+
return walkList(rendered, scope, `${key}/`, out);
|
|
80
|
+
}
|
|
81
|
+
const { children, ...props } = el.props;
|
|
82
|
+
const node = { tag: type, props, key, children: [] };
|
|
83
|
+
walkList(children, scope, "", node.children);
|
|
84
|
+
out.push(node);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/runtime/jsx-runtime.ts
|
|
88
|
+
function jsx(type, props, key) {
|
|
89
|
+
return createElement(type, props, key ?? null);
|
|
90
|
+
}
|
|
91
|
+
var jsxs = jsx;
|
|
92
|
+
var jsxDEV = jsx;
|
|
93
|
+
|
|
94
|
+
export { Fragment, LocalContext, createContext, createElement, isElement, jsx, jsxDEV, jsxs, localStore, resolve, useCallback, useContext, useLocal, useMemo };
|
|
95
|
+
//# sourceMappingURL=chunk-HQ6ICBI7.js.map
|
|
96
|
+
//# sourceMappingURL=chunk-H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AE;AAC7D,EAAA,QAAA,CAAS,QAAA,EAAmB,KAAA,EAAO,EAAA,EAAI,IAAA,CAAK,QAAQ,CAAA;AACpD,EAAA,GAAA,CAAI,KAAK,IAAI,CAAA;AACf;;;ACvKO,SAAS,GAAA,CAAI,IAAA,EAAuB,KAAA,EAAc,GAAA,EAAgC;AACvF,EAAA,OAAO,aAAA,CAAc,IAAA,EAAM,KAAA,EAAO,GAAA,IAAO,IAAI,CAAA;AAC/C;AACO,IAAM,IAAA,GAAO;AACb,IAAM,MAAA,GAAS","file":"chunk-HQ6ICBI7.js","sourcesContent":["/**\n * The drawing runtime: renderers are plain functions that return elements\n * (written as JSX), and `resolve` turns them into a tree of SVG and HTML\n * elements. No framework: a host turns the tree into markup (`toMarkup`),\n * into the DOM (`mount`), or into its own framework's elements.\n *\n * A renderer reads what its host gives it through contexts, and keeps a\n * small amount of state (an open group, a hovered line) in a store that the\n * host owns, by name (`useLocal`). There are no effects and no refs: the\n * same input always draws the same tree.\n */\n\nexport type Props = Record<string, unknown>\n\n/** A component: props in, elements out. */\nexport type Component<P = Props> = (props: P) => Child\n\nexport const Fragment = Symbol.for('poney.fragment')\n\nexport interface Element {\n readonly $$poney: true\n readonly type: string | Component<never> | typeof Fragment\n readonly props: Props\n readonly key: string | number | null\n}\n\nexport type Child = Element | string | number | bigint | boolean | null | undefined | readonly Child[]\n\n/** An SVG or HTML element after resolution: only tags, attributes and children. */\nexport interface HostNode {\n tag: string\n /** Attributes and event handlers, with the names a JSX author wrote (strokeWidth, onClick). */\n props: Props\n /** Unique among its siblings: the author's key, or the position in the JSX. */\n key: string\n children: Resolved[]\n}\nexport type Resolved = HostNode | string\n\nexport function createElement(type: Element['type'], props: Props, key: string | number | null = null): Element {\n return { $$poney: true, type, props, key }\n}\n\nexport const isElement = (x: unknown): x is Element => typeof x === 'object' && x !== null && (x as Element).$$poney === true\n\n/* ─── Contexts ─────────────────────────────────────────────────────────────── */\n\nexport interface Context<T> {\n readonly id: symbol\n readonly fallback: T\n readonly Provider: Component<{ value: T; children?: Child }>\n}\n\ninterface Scope {\n readonly parent: Scope | null\n readonly id: symbol\n readonly value: unknown\n}\n\nconst providers = new WeakMap<Component<never>, symbol>()\n\nexport function createContext<T>(fallback: T): Context<T> {\n const id = Symbol('poney.context')\n // Never called: resolve sees the Provider and puts its value in scope.\n const Provider: Component<{ value: T; children?: Child }> = (p) => p.children\n providers.set(Provider as Component<never>, id)\n return { id, fallback, Provider }\n}\n\nlet current: Scope | null = null\nlet resolving = false\n\nexport function useContext<T>(ctx: Context<T>): T {\n if (!resolving) throw new Error('useContext is only for components while they draw')\n for (let s = current; s; s = s.parent) if (s.id === ctx.id) return s.value as T\n return ctx.fallback\n}\n\n/** A renderer draws again for each change: a memo is the value itself. */\nexport const useMemo = <T>(make: () => T, _deps?: readonly unknown[]): T => make()\nexport const useCallback = <T>(fn: T, _deps?: readonly unknown[]): T => fn\n\n/* ─── Local state, kept by the host ────────────────────────────────────────── */\n\n/**\n * Where renderers keep their small state, by name. The host owns it and\n * draws again after a change. A still picture has none: `set` is ignored.\n */\nexport interface LocalStore {\n get(key: string): unknown\n has(key: string): boolean\n /** Changes a value from the one the host has now (not the one last drawn). */\n update(key: string, change: (prev: unknown) => unknown): void\n}\n\nconst still: LocalStore = { get: () => undefined, has: () => false, update: () => {} }\nexport const LocalContext = createContext<LocalStore>(still)\n\n/** A store in a Map, for a host that draws again with `redraw` after each change. */\nexport function localStore(redraw: () => void, values = new Map<string, unknown>()): LocalStore {\n return {\n get: (key) => values.get(key),\n has: (key) => values.has(key),\n update(key, change) {\n values.set(key, change(values.get(key)))\n redraw()\n },\n }\n}\n\n/**\n * A value that the host keeps between drawings, by a name unique in the\n * drawing (for example `map:${view.id}:hot`).\n */\nexport function useLocal<T>(key: string, initial: T): [T, (next: T | ((prev: T) => T)) => void] {\n const store = useContext(LocalContext)\n const value = store.has(key) ? (store.get(key) as T) : initial\n const set = (next: T | ((prev: T) => T)) =>\n store.update(key, (prev) => {\n const base = prev === undefined ? initial : (prev as T)\n return typeof next === 'function' ? (next as (p: T) => T)(base) : next\n })\n return [value, set]\n}\n\n/* ─── Resolution ───────────────────────────────────────────────────────────── */\n\n/** Draws elements into a tree of SVG and HTML elements. */\nexport function resolve(child: Child): Resolved[] {\n const was = { current, resolving }\n resolving = true\n try {\n const out: Resolved[] = []\n walkList(child, null, '', out)\n return out\n } finally {\n current = was.current\n resolving = was.resolving\n }\n}\n\n/**\n * Every element gets a key from where it stands in the JSX, as in React: its\n * own key inside its list, or its position. A nested list adds its position\n * as a prefix, so two lists never share a key and a list that grows does not\n * move the keys of the elements after it.\n */\nfunction walkList(children: Child, scope: Scope | null, prefix: string, out: Resolved[]): void {\n if (!Array.isArray(children)) return walkOne(children as Child, scope, prefix, '0', out)\n const list = children as readonly Child[]\n for (let i = 0; i < list.length; i++) {\n const item = list[i]\n if (Array.isArray(item)) walkList(item, scope, `${prefix}${i}.`, out)\n else walkOne(item, scope, prefix, String(i), out)\n }\n}\n\nfunction walkOne(child: Child, scope: Scope | null, prefix: string, slot: string, out: Resolved[]): void {\n if (child === null || child === undefined || typeof child === 'boolean') return\n if (typeof child === 'string') return void out.push(child)\n if (typeof child === 'number' || typeof child === 'bigint') return void out.push(String(child))\n const el = child as Element\n const key = el.key === null ? `${prefix}${slot}` : `${prefix}=${el.key}`\n const { type } = el\n if (type === Fragment) return walkList(el.props.children as Child, scope, `${key}/`, out)\n if (typeof type === 'function') {\n const id = providers.get(type)\n if (id) return walkList(el.props.children as Child, { parent: scope, id, value: el.props.value }, `${key}/`, out)\n current = scope\n const rendered = (type as Component<Props>)(el.props)\n return walkList(rendered, scope, `${key}/`, out)\n }\n const { children, ...props } = el.props\n const node: HostNode = { tag: type, props, key, children: [] }\n walkList(children as Child, scope, '', node.children)\n out.push(node)\n}\n","/**\n * The JSX runtime for Poney renderers: `@jsxImportSource @hattoriai/poney-diagrams`.\n * JSX makes plain elements; `resolve` draws them.\n */\nimport { createElement, Fragment, type Child, type Element, type Props } from './core'\nimport type { PoneyEvent, PoneyKeyboardEvent, PoneyMouseEvent } from './events'\n\nexport { Fragment }\n\nexport function jsx(type: Element['type'], props: Props, key?: string | number): Element {\n return createElement(type, props, key ?? null)\n}\nexport const jsxs = jsx\nexport const jsxDEV = jsx\n\n/** What a renderer may put on an element: attributes, handlers and children. */\nexport interface ElementProps {\n [name: string]: unknown\n children?: Child\n key?: string | number | null\n style?: Record<string, string | number | undefined>\n onClick?: (e: PoneyMouseEvent) => void\n onDoubleClick?: (e: PoneyMouseEvent) => void\n onMouseEnter?: (e: PoneyMouseEvent) => void\n onMouseLeave?: (e: PoneyMouseEvent) => void\n onPointerDown?: (e: PoneyMouseEvent) => void\n onFocus?: (e: PoneyEvent) => void\n onBlur?: (e: PoneyEvent) => void\n onKeyDown?: (e: PoneyKeyboardEvent) => void\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace JSX {\n export type Element = import('./core').Element\n /** A component may return any child: an element, text, a list or nothing. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n export type ElementType = string | ((props: any) => Child)\n export interface ElementChildrenAttribute {\n children: unknown\n }\n export interface IntrinsicAttributes {\n key?: string | number | null\n }\n export interface IntrinsicElements {\n [tag: string]: ElementProps\n }\n}\n"]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource @hattoriai/poney-diagrams */
|
|
3
|
+
import { type Child } from './runtime';
|
|
4
|
+
import type { Badge, ChangeState, Effect } from '@hattoriai/poney-core';
|
|
5
|
+
/**
|
|
6
|
+
* How a story renderer shows the change.
|
|
7
|
+
*
|
|
8
|
+
* - "before": the system before the change. New elements are hidden.
|
|
9
|
+
* - "change": the change itself. New, changed and removed elements are coloured.
|
|
10
|
+
* - "after": the system after the change. Removed elements are hidden.
|
|
11
|
+
*/
|
|
12
|
+
export type Mode = 'before' | 'change' | 'after';
|
|
13
|
+
export interface StoryState {
|
|
14
|
+
marks: Map<string, ChangeState>;
|
|
15
|
+
mode: Mode;
|
|
16
|
+
/** Elements the scene is about. Everything else dims. Null: nothing dims. */
|
|
17
|
+
focus: Set<string> | null;
|
|
18
|
+
/** Numbered callouts by element. */
|
|
19
|
+
callouts: Map<string, number>;
|
|
20
|
+
/** The element under the reader's attention: hovered here or in the text. */
|
|
21
|
+
hot: string | null;
|
|
22
|
+
setHot(key: string | null): void;
|
|
23
|
+
/** Show relationship labels on every edge, not only on focused ones. */
|
|
24
|
+
allLabels?: boolean;
|
|
25
|
+
/** Opens or closes a group in a map. Without it, groups cannot be toggled (a static picture). */
|
|
26
|
+
toggleGroup?(entityId: string): void;
|
|
27
|
+
/** Effects and badges by ref key. */
|
|
28
|
+
effects?: Map<string, Effect[]>;
|
|
29
|
+
badges?: Map<string, Badge[]>;
|
|
30
|
+
/**
|
|
31
|
+
* The path the reader can play: its steps as ref keys, the step shown
|
|
32
|
+
* (null: not playing), whether to animate, and whether a still picture
|
|
33
|
+
* numbers the steps.
|
|
34
|
+
*/
|
|
35
|
+
trace?: {
|
|
36
|
+
steps: string[];
|
|
37
|
+
current: number | null;
|
|
38
|
+
animate: boolean;
|
|
39
|
+
numbered: boolean;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export declare const StoryProvider: ({ value, children }: {
|
|
43
|
+
value: StoryState;
|
|
44
|
+
children?: Child;
|
|
45
|
+
}) => import("./runtime").Element;
|
|
46
|
+
export declare const useStory: () => StoryState;
|
|
47
|
+
export interface Look {
|
|
48
|
+
/** The change state, shown only in "change" mode. */
|
|
49
|
+
state?: ChangeState;
|
|
50
|
+
hidden: boolean;
|
|
51
|
+
dim: boolean;
|
|
52
|
+
hot: boolean;
|
|
53
|
+
focused: boolean;
|
|
54
|
+
callout?: number;
|
|
55
|
+
}
|
|
56
|
+
/** How one element should look in the current story state. */
|
|
57
|
+
export declare function useLook(key: string): Look;
|
|
58
|
+
/** One look for an element that stands for several (a line through a hidden hop). */
|
|
59
|
+
export declare function useLookAny(keys: string[]): Look;
|
|
60
|
+
export declare function lookOf(s: StoryState, key: string): Look;
|
|
61
|
+
export declare const lookClass: (l: Look) => string;
|
|
62
|
+
export declare const stateStroke: (s?: ChangeState, fallback?: string) => string;
|
|
63
|
+
export declare const stateFill: (s?: ChangeState, fallback?: string) => string;
|
|
64
|
+
export declare const STATE_LABEL: Record<ChangeState, string>;
|
|
65
|
+
/** A small label that says New, Changed or Removed, centred on a point. */
|
|
66
|
+
export declare function StateTag({ state, x, y, anchor }: {
|
|
67
|
+
state?: ChangeState;
|
|
68
|
+
x: number;
|
|
69
|
+
y: number;
|
|
70
|
+
anchor?: 'start' | 'end' | 'middle';
|
|
71
|
+
}): import("./runtime").Element | null;
|
|
72
|
+
/** A numbered marker that ties the diagram to a note in the text. */
|
|
73
|
+
export declare function CalloutBadge({ n, x, y, hot }: {
|
|
74
|
+
n: number;
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
hot?: boolean;
|
|
78
|
+
}): import("./runtime").Element;
|
|
79
|
+
/** A filled arrowhead at the end of a line. */
|
|
80
|
+
export declare function Head({ x, y, angle, color, size }: {
|
|
81
|
+
x: number;
|
|
82
|
+
y: number;
|
|
83
|
+
angle: number;
|
|
84
|
+
color: string;
|
|
85
|
+
size?: number;
|
|
86
|
+
}): import("./runtime").Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ViewOf } from '@hattoriai/poney-core';
|
|
2
|
+
import { type ActivityScene } from '@hattoriai/poney-layout';
|
|
3
|
+
import type { DiagramModule } from '../types';
|
|
4
|
+
type View = ViewOf<'activity'>;
|
|
5
|
+
export declare const activity: DiagramModule<View, ActivityScene>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ViewOf } from '@hattoriai/poney-core';
|
|
2
|
+
import { type ArchitectureScene } from '@hattoriai/poney-layout';
|
|
3
|
+
import type { DiagramModule } from '../types';
|
|
4
|
+
type View = ViewOf<'architecture'>;
|
|
5
|
+
export declare const architecture: DiagramModule<View, ArchitectureScene>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ViewOf } from '@hattoriai/poney-core';
|
|
2
|
+
import { type DataFlowScene } from '@hattoriai/poney-layout';
|
|
3
|
+
import type { DiagramModule } from '../types';
|
|
4
|
+
type View = ViewOf<'dataflow'>;
|
|
5
|
+
export declare const dataflow: DiagramModule<View, DataFlowScene>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ViewOf } from '@hattoriai/poney-core';
|
|
2
|
+
import { type DependencyScene } from '@hattoriai/poney-layout';
|
|
3
|
+
import type { DiagramModule } from '../types';
|
|
4
|
+
type View = ViewOf<'dependency'>;
|
|
5
|
+
export declare const dependency: DiagramModule<View, DependencyScene>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diagram renderers for every core view type: architecture, map, sequence,
|
|
3
|
+
* data flow, activity, ERD, state, use case and dependency. Each draws a
|
|
4
|
+
* scene laid out by @hattoriai/poney-layout as SVG, in any React app or headless.
|
|
5
|
+
* Interaction, selection and view state come from the host through
|
|
6
|
+
* RenderProvider; without one, a diagram is a still picture.
|
|
7
|
+
*/
|
|
8
|
+
export { BUILT_IN_DIAGRAMS, registerDiagram, diagramFor, diagramByKey } from './registry';
|
|
9
|
+
export { viewKey, type DiagramModule, type AnyDiagramModule } from './types';
|
|
10
|
+
export { EntityNode, Rings, useReadableSize } from './shared/EntityNode';
|
|
11
|
+
export { EdgeLabel, EdgeLine, type Head as EdgeHead } from './shared/Edge';
|
|
12
|
+
export { LegendRow, LegendShape } from './shared/Legend';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { View } from '@hattoriai/poney-core';
|
|
2
|
+
import { type AnyDiagramModule } from './types';
|
|
3
|
+
/** The core diagram types. Extensions add theirs with registerDiagram. */
|
|
4
|
+
export declare const BUILT_IN_DIAGRAMS: AnyDiagramModule[];
|
|
5
|
+
/** Adds (or replaces) the renderer for a view type, e.g. an extension's "ownership/team-map". */
|
|
6
|
+
export declare function registerDiagram(module: AnyDiagramModule): void;
|
|
7
|
+
/** The renderer for a view, if one is registered. */
|
|
8
|
+
export declare function diagramFor(view: View): AnyDiagramModule | undefined;
|
|
9
|
+
export declare function diagramByKey(key: string): AnyDiagramModule | undefined;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ViewOf } from '@hattoriai/poney-core';
|
|
2
|
+
import { type SequenceScene } from '@hattoriai/poney-layout';
|
|
3
|
+
import type { DiagramModule } from '../types';
|
|
4
|
+
type View = ViewOf<'sequence'>;
|
|
5
|
+
export declare const sequence: DiagramModule<View, SequenceScene>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource @hattoriai/poney-diagrams */
|
|
3
|
+
import { type Point } from '@hattoriai/poney-layout';
|
|
4
|
+
export type Head = 'arrow' | 'open-arrow' | 'triangle' | 'none';
|
|
5
|
+
/** Arrowhead geometry drawn as a path, so it always matches the line color. */
|
|
6
|
+
export declare function ArrowHead({ at, angle, kind, color, size }: {
|
|
7
|
+
at: Point;
|
|
8
|
+
angle: number;
|
|
9
|
+
kind: Head;
|
|
10
|
+
color: string;
|
|
11
|
+
size?: number;
|
|
12
|
+
}): import("../..").Element | null;
|
|
13
|
+
export interface EdgeStyle {
|
|
14
|
+
color: string;
|
|
15
|
+
width: number;
|
|
16
|
+
dash?: string;
|
|
17
|
+
head: Head;
|
|
18
|
+
tail?: Head;
|
|
19
|
+
opacity?: number;
|
|
20
|
+
flowing?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** A routed edge with an invisible wide hit area for easy pointing. */
|
|
23
|
+
export declare function EdgeLine({ points, style, radius }: {
|
|
24
|
+
points: Point[];
|
|
25
|
+
style: EdgeStyle;
|
|
26
|
+
radius?: number;
|
|
27
|
+
}): import("../..").Element;
|
|
28
|
+
/** A label pill centered on a point. */
|
|
29
|
+
export declare function EdgeLabel({ at, text, secondary, tone, strong, size, }: {
|
|
30
|
+
at: Point;
|
|
31
|
+
text: string;
|
|
32
|
+
secondary?: string;
|
|
33
|
+
tone?: string;
|
|
34
|
+
strong?: boolean;
|
|
35
|
+
size?: number;
|
|
36
|
+
}): import("../..").Element;
|
|
37
|
+
/** Size of an EdgeLabel, for layouts that reserve space. */
|
|
38
|
+
export declare function labelSize(text: string, secondary?: string, size?: number): {
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Entity, ResolvedStyle } from '@hattoriai/poney-core';
|
|
2
|
+
/**
|
|
3
|
+
* Semantic zoom: the font size, in diagram units, that keeps text at least
|
|
4
|
+
* `screen` pixels tall on screen, in steps so layouts can be cached.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useReadableSize(base: number, screen?: number, max?: number): number;
|
|
7
|
+
export type Emphasis = 'normal' | 'selected' | 'dim';
|
|
8
|
+
interface Props {
|
|
9
|
+
entity: Entity;
|
|
10
|
+
style: ResolvedStyle;
|
|
11
|
+
w: number;
|
|
12
|
+
h: number;
|
|
13
|
+
emphasis: Emphasis;
|
|
14
|
+
/** Show the summary text (level of detail). */
|
|
15
|
+
detail: boolean;
|
|
16
|
+
/** Footer text, for example "17 parts inside". */
|
|
17
|
+
footer?: string;
|
|
18
|
+
}
|
|
19
|
+
/** Selection ring and keyboard focus ring around a node box. */
|
|
20
|
+
export declare function Rings({ w, h, rx, selected }: {
|
|
21
|
+
w: number;
|
|
22
|
+
h: number;
|
|
23
|
+
rx?: number;
|
|
24
|
+
selected: boolean;
|
|
25
|
+
}): import("../..").Element;
|
|
26
|
+
/**
|
|
27
|
+
* The visual treatment of one entity, by shape: card, cylinder (stores),
|
|
28
|
+
* stack (queues), person, chip (code modules) and frame (a closed system).
|
|
29
|
+
* Drawn at the origin; the caller positions it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function EntityNode({ entity, style, w, h, emphasis, detail, footer }: Props): import("../..").Element;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** A miniature of a node shape with its label, for diagram keys. */
|
|
2
|
+
export declare function LegendShape({ shape, tone, label, dashed }: {
|
|
3
|
+
shape: string;
|
|
4
|
+
tone: string;
|
|
5
|
+
label: string;
|
|
6
|
+
dashed?: boolean;
|
|
7
|
+
}): import("../..").Element;
|
|
8
|
+
/** A line sample with its label. */
|
|
9
|
+
export declare function LegendRow({ line, label, color, head }: {
|
|
10
|
+
line: 'solid' | 'dashed' | 'dotted';
|
|
11
|
+
label: string;
|
|
12
|
+
color?: string;
|
|
13
|
+
head?: boolean;
|
|
14
|
+
}): import("../..").Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ICONS, iconFor, Glyph } from '../../icons';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { toneColor, toneWash } from '../../tone';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Component } from '../runtime';
|
|
2
|
+
import type { IconData } from '../icons';
|
|
3
|
+
import type { View } from '@hattoriai/poney-core';
|
|
4
|
+
import type { SceneBase } from '@hattoriai/poney-layout';
|
|
5
|
+
export type { Rect, Point, SceneBase } from '@hattoriai/poney-layout';
|
|
6
|
+
/**
|
|
7
|
+
* A renderer draws one kind of view from a positioned scene. It never
|
|
8
|
+
* computes layout and never changes the model; it reads the scene, and from
|
|
9
|
+
* its host (RenderProvider) the selection, the hover and the view's state.
|
|
10
|
+
*/
|
|
11
|
+
export interface DiagramModule<V extends View = View, S extends SceneBase = SceneBase> {
|
|
12
|
+
/** "architecture", "sequence"… or "<extension>/<view>" for extension views. */
|
|
13
|
+
key: string;
|
|
14
|
+
label: string;
|
|
15
|
+
icon: IconData;
|
|
16
|
+
/** How to read this kind of diagram, in one or two sentences. */
|
|
17
|
+
howToRead: string;
|
|
18
|
+
Renderer: Component<{
|
|
19
|
+
scene: S;
|
|
20
|
+
view: V;
|
|
21
|
+
}>;
|
|
22
|
+
/** How a host should first frame this diagram: all of it, or its start (e.g. the top of a long sequence). */
|
|
23
|
+
initialView?: 'fit' | 'start';
|
|
24
|
+
/** Key to the symbols, for a host to show next to the diagram. */
|
|
25
|
+
Legend?: Component<{
|
|
26
|
+
view: V;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
export type AnyDiagramModule = DiagramModule<any, any>;
|
|
30
|
+
export declare const viewKey: (view: View) => string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ViewOf } from '@hattoriai/poney-core';
|
|
2
|
+
import { type UseCaseScene } from '@hattoriai/poney-layout';
|
|
3
|
+
import type { DiagramModule } from '../types';
|
|
4
|
+
type View = ViewOf<'usecase'>;
|
|
5
|
+
export declare const usecase: DiagramModule<View, UseCaseScene>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
2
|
+
/** @jsxImportSource @hattoriai/poney-diagrams */
|
|
3
|
+
import { type View } from '@hattoriai/poney-core';
|
|
4
|
+
import { type Point, type SceneBase } from '@hattoriai/poney-layout';
|
|
5
|
+
import type { Element } from './runtime';
|
|
6
|
+
/**
|
|
7
|
+
* Emphasis: effects, badges and the trace, drawn over any story scene.
|
|
8
|
+
*
|
|
9
|
+
* The document says what a reader must see (data flows here, this is slow,
|
|
10
|
+
* the request goes this way); this file decides how. Lines get a soft band
|
|
11
|
+
* under them and moving dots on them; boxes get a ring and a sign; the trace
|
|
12
|
+
* moves a token along its path. A still picture keeps every mark but the
|
|
13
|
+
* motion. Readers who ask for less motion get no motion.
|
|
14
|
+
*/
|
|
15
|
+
/** A line in a scene: its path, and a point at any fraction of its length. */
|
|
16
|
+
export interface LineShape {
|
|
17
|
+
d: string;
|
|
18
|
+
at(t: number): Point & {
|
|
19
|
+
angle: number;
|
|
20
|
+
};
|
|
21
|
+
/** Where a step mark sits, clear of the label. */
|
|
22
|
+
stepAt: number;
|
|
23
|
+
/** Where a badge sits: under the line's label when it has one. */
|
|
24
|
+
badge: Point;
|
|
25
|
+
/** Where a sign (slow, failing, blocked) sits: after the label when it has one. */
|
|
26
|
+
sign: Point;
|
|
27
|
+
}
|
|
28
|
+
/** The shape of every line in a scene, by ref key. Boxes come from the scene's anchors. */
|
|
29
|
+
export declare function sceneLines(scene: SceneBase, view: View): Map<string, LineShape>;
|
|
30
|
+
declare const keyOf: (k: string) => string;
|
|
31
|
+
/** Bands under lines: drawn before the scene, so they never cover a label. */
|
|
32
|
+
export declare function EmphasisUnder({ scene, view }: {
|
|
33
|
+
scene: SceneBase;
|
|
34
|
+
view: View;
|
|
35
|
+
}): Element | null;
|
|
36
|
+
/** Marks over the scene: moving dots, rings, signs, badges and the trace. */
|
|
37
|
+
export declare function EmphasisOver({ scene, view }: {
|
|
38
|
+
scene: SceneBase;
|
|
39
|
+
view: View;
|
|
40
|
+
}): Element | null;
|
|
41
|
+
/** Steps of a path are lettered (A, B, C), so they never read as a callout or a message number. */
|
|
42
|
+
export declare const stepLetter: (i: number) => string;
|
|
43
|
+
export { keyOf as emphasisKey };
|
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A page with no framework as the host: `drawInto` draws a renderer into an
|
|
3
|
+
* element of the page, with the host's values, and draws again after each
|
|
4
|
+
* local change (an open group, a hovered line).
|
|
5
|
+
*/
|
|
6
|
+
import { type StoryState } from './context';
|
|
7
|
+
import { type RenderValue } from './render';
|
|
8
|
+
import { type Component } from './runtime';
|
|
9
|
+
export interface Host {
|
|
10
|
+
/** The model index, and optionally interaction, selection and view state. */
|
|
11
|
+
render: RenderValue;
|
|
12
|
+
/** How a story drawing shows a change. */
|
|
13
|
+
story?: StoryState;
|
|
14
|
+
/** The zoom level, for level-of-detail drawing. Default: 1. */
|
|
15
|
+
zoom?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface Drawing<P> {
|
|
18
|
+
/** Draws again, with new host values and new props when given. */
|
|
19
|
+
update(next?: Partial<Host>, props?: P): void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Draws `component` with `props` into `container` (an `<svg>` or a `<g>` for
|
|
23
|
+
* diagrams, any element for a legend). Elements keep their identity between
|
|
24
|
+
* drawings, so focus, hover and CSS transitions survive.
|
|
25
|
+
*/
|
|
26
|
+
export declare function drawInto<P extends object>(container: Element, component: Component<P>, props: P, host: Host): Drawing<P>;
|